Package com.kii.cloud.storage
Class KiiThing
- java.lang.Object
-
- com.kii.cloud.storage.KiiBaseObject
-
- com.kii.cloud.storage.KiiThing
-
- All Implemented Interfaces:
android.os.Parcelable
,KiiPushMessageSender
,KiiSubject
public class KiiThing extends KiiBaseObject implements android.os.Parcelable, KiiSubject, KiiPushMessageSender
Represent Thing on KiiCloud. There are two types of property of KiiThing, reserve and custom.
Reserve fields
Reserve keys can not be used as the key of setter methods of KiiThing.
To set/get the value of these reserve fields, you use the setter/getter methods of these field.
- _thingID
- _vendorThingID
- _password
- _thingType
- _vendor
- _firmwareVersion
- _productName
- _lot
- _created
- _stringField1
- _stringField2
- _stringField3
- _stringField4
- _stringField5
- _numberField1
- _numberField2
- _numberField3
- _numberField4
- _numberField5
- _accessToken
Custom Fields
Custom field includes any field choose by you, other than reserve field.
Custom field can have String, integer, long, double, JSONArray, byte[], Uri type values.
setter/getter method of these type can be use to set/get the custom field.
NOTE: KiiThing does not support removal of fields from Server.
-
-
Field Summary
Fields Modifier and Type Field Description static android.os.Parcelable.Creator<KiiThing>
CREATOR
-
Fields inherited from class com.kii.cloud.storage.KiiBaseObject
mJSON, mJSONPatch
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KiiBucket
bucket(java.lang.String bucketName)
Returns bucket belongs to this thing.void
delete()
Delete the thing.void
delete(KiiCallback<KiiThing> callback)
Asynchronous version ofdelete()
Background task will be initiated to execute the task.int
describeContents()
void
disable()
Disable the thing.void
disable(KiiCallback<KiiThing> callback)
Asynchronous version ofdisable()
Background task will be initiated to execute the task.boolean
disabled()
Return true if the thing is disabled, false otherwise.void
enable()
Enable the thing.void
enable(KiiCallback<KiiThing> callback)
Asynchronous version ofenable()
Background task will be initiated to execute the task.KiiEncryptedBucket
encryptedBucket(java.lang.String bucketName)
Returns the KiiEncryptedBucket instance belongs to this thing.java.lang.String
getAccessToken()
Get the AccessToken of this thing.long
getCreatedTime()
Get the created time of this thing.java.lang.String
getFirmwareVersion()
Get the FirmwareVersion of this thing.java.lang.String
getID()
Get the ThingID of this thing.java.lang.String
getLot()
Get the Lot of this thing.java.lang.Long
getNumberField1()
Get the NumberField1 of this thing.java.lang.Long
getNumberField2()
Get the NumberField2 of this thing.java.lang.Long
getNumberField3()
Get the NumberField3 of this thing.java.lang.Long
getNumberField4()
Get the NumberField4 of this thing.java.lang.Long
getNumberField5()
Get the NumberField5 of this thing.long
getOnlineStatusModifiedAt()
Get online status modified date of the thing.java.lang.String
getProductName()
Get the ProductName of this thing.java.lang.String
getStringField1()
Get the StringField1 of this thing.java.lang.String
getStringField2()
Get the StringField2 of this thing.java.lang.String
getStringField3()
Get the StringField3 of this thing.java.lang.String
getStringField4()
Get the StringField4 of this thing.java.lang.String
getStringField5()
Get the StringField5 of this thing.java.lang.String
getThingType()
Get the ThingType of this thing.java.lang.String
getVendor()
Get the Vendor of this thing.java.lang.String
getVendorThingID()
Get the VendorThingID of this thing.java.lang.Boolean
isOnline()
Get online status of the thing.boolean
isOwner(KiiThingOwner owner)
Check if user/ group is owner of the thing.void
isOwner(KiiThingOwner owner, KiiCallback<java.lang.Boolean> callback)
Asynchronous version ofisOwner(KiiThingOwner)
Background task will be initiated to execute the task.static boolean
isValidThingGenericField(java.lang.String field)
Checks whether the generic field of thing is valid or not.
Valid generic field of thing definition is: Matches [a-zA-Z0-9-_\\.static boolean
isValidThingPassword(java.lang.String password)
Checks whether the thing password is valid or not.
Valid thing password definition is: Not null or empty Matches ^\\p{Print}{1,200}$static boolean
isValidVendorThingID(java.lang.String vendorThingID)
Checks whether the vendorThingID is valid or not.
Valid vendorThingID definition is: Not null or empty Matches [a-zA-Z0-9-_\\.]{1,200}KiiListResult<KiiTopic>
listTopics()
Returns the list of topics in this thing scope.void
listTopics(KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
.KiiListResult<KiiTopic>
listTopics(java.lang.String paginationKey)
Returns the next page of list of topics in this thing scope.void
listTopics(java.lang.String paginationKey, KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
.static KiiThing
loadWithThingID(java.lang.String thingId)
Load registered thing with thingId.static void
loadWithThingID(java.lang.String thingId, KiiCallback<KiiThing> callback)
Asynchronous version ofloadWithVendorThingID(String)
Background task will be initiated to execute the task.static KiiThing
loadWithVendorThingID(java.lang.String vendorThingID)
Load registered thing with vendorThingID.static void
loadWithVendorThingID(java.lang.String vendorThingID, KiiCallback<KiiThing> callback)
Asynchronous version ofloadWithVendorThingID(String)
Background task will be initiated to execute the task.KiiPushSubscription
pushSubscription()
Get KiiPushSubscription instance of the thing.static KiiThingQueryResult
query(KiiThingQuery query)
The query operation returns a list of KiiThing that matches the query expression.static void
query(KiiThingQuery query, KiiCallback<KiiThingQueryResult> callback)
Asynchronous version ofquery(KiiThingQuery)
.
Background task will be initiated to execute the task.void
refresh()
Refresh thing.void
refresh(KiiCallback<KiiThing> callback)
Asynchronous version ofrefresh()
Background task will be initiated to execute the task.static KiiThing
register(java.lang.String vendorThingID, java.lang.String password, java.lang.String thingType, ThingFields thingFields)
Register thing in Kii Cloud.static void
register(java.lang.String vendorThingID, java.lang.String password, java.lang.String thingType, ThingFields thingFields, KiiCallback<KiiThing> callback)
Asynchronous version ofregister(String, String, String, ThingFields)
Background task will be initiated to execute the task.void
registerOwner(KiiThingOwner owner, java.lang.String password)
Register owner of the thing.void
registerOwner(KiiThingOwner owner, java.lang.String password, KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwner(KiiThingOwner, String)
Background task will be initiated to execute the task.static void
registerOwnerWithThingID(java.lang.String thingID, KiiThingOwner owner, java.lang.String password)
Register owner of specified thing.static void
registerOwnerWithThingID(java.lang.String thingID, KiiThingOwner owner, java.lang.String password, KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwnerWithThingID(String, KiiThingOwner, String)
Background task will be initiated to execute the task.static void
registerOwnerWithVendorThingID(java.lang.String vendorThingID, KiiThingOwner owner, java.lang.String password)
Register owner of specified thing.static void
registerOwnerWithVendorThingID(java.lang.String vendorThingID, KiiThingOwner owner, java.lang.String password, KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwnerWithVendorThingID(String, KiiThingOwner, String)
Background task will be initiated to execute the task.void
setFirmwareVersion(java.lang.String value)
Set the FirmwareVersion of this thing.void
setLot(java.lang.String value)
Set the Lot of this thing.void
setNumberField1(java.lang.Long value)
Set the NumberField1 of this thing.void
setNumberField2(java.lang.Long value)
Set the NumberField2 of this thing.void
setNumberField3(java.lang.Long value)
Set the NumberField3 of this thing.void
setNumberField4(java.lang.Long value)
Set the NumberField4 of this thing.void
setNumberField5(java.lang.Long value)
Set the NumberField5 of this thing.void
setProductName(java.lang.String value)
Set the ProductName of this thing.void
setStringField1(java.lang.String value)
Set the StringField1 of this thing.void
setStringField2(java.lang.String value)
Set the StringField2 of this thing.void
setStringField3(java.lang.String value)
Set the StringField3 of this thing.void
setStringField4(java.lang.String value)
Set the StringField4 of this thing.void
setStringField5(java.lang.String value)
Set the StringField5 of this thing.void
setThingType(java.lang.String value)
Set the ThingType of this thing.void
setVendor(java.lang.String value)
Set the Vendor of this thing.static KiiThing
thingWithID(java.lang.String thingID)
Instantiate KiiThing that refers to existing thing which has specified ID.KiiTopic
topic(java.lang.String name)
Get instance of thing scope topic.void
unregisterOwner(KiiThingOwner owner)
Remove ownership of the thing from specified user/ group.void
unregisterOwner(KiiThingOwner owner, KiiCallback<KiiThingOwner> callback)
Asynchronous version ofunregisterOwner(KiiThingOwner)
Background task will be initiated to execute the task.void
update()
Update the thing information.void
update(KiiCallback<KiiThing> callback)
Asynchronous version ofupdate()
Background task will be initiated to execute the task.void
writeToParcel(android.os.Parcel dest, int flags)
-
Methods inherited from class com.kii.cloud.storage.KiiBaseObject
getBoolean, getBoolean, getByteArray, getDouble, getDouble, getInt, getInt, getJsonArray, getJSONArray, getJSONObject, getJSONOfArbitraryFields, getLong, getLong, getObject, getObject, getString, getString, getUri, has, keySet, remove, removeReserveProperty, set, set, set, set, set, set, set, set, set
-
-
-
-
Field Detail
-
CREATOR
public static final android.os.Parcelable.Creator<KiiThing> CREATOR
-
-
Method Detail
-
thingWithID
@NonNull public static KiiThing thingWithID(@NonNull java.lang.String thingID)
Instantiate KiiThing that refers to existing thing which has specified ID. You have to specify the ID of existing KiiThing. Unlike KiiObject, you can not assign ID in the client side. After instantiation, callrefresh()
to fetch the properties.- Parameters:
thingID
- ID of the KiiThing to instantiate.- Returns:
- instance of KiiThing.
- Throws:
java.lang.IllegalArgumentException
- when passed thingID is empty or null.- See Also:
getID()
-
registerOwnerWithThingID
@WorkerThread public static void registerOwnerWithThingID(@NonNull java.lang.String thingID, @NonNull KiiThingOwner owner, @NonNull java.lang.String password) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Register owner of specified thing. After the registration, owner can access the thing, buckets, objects in bucket, and topics belongs to the thing.
This api is authorized by owner of the Thing.
Need user login before execute this API.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
thingID
-owner
- to be registered as ownerpassword
- the thing password- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
UndefinedException
-
registerOwnerWithVendorThingID
@WorkerThread public static void registerOwnerWithVendorThingID(@NonNull java.lang.String vendorThingID, @NonNull KiiThingOwner owner, @NonNull java.lang.String password) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Register owner of specified thing. After the registration, owner can access the thing, buckets, objects in bucket, and topics belongs to the thing.
This api is authorized by owner of the Thing.
Need user login before execute this API.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
vendorThingID
-owner
- to be registered as ownerpassword
- the thing password- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
UndefinedException
-
registerOwnerWithThingID
public static void registerOwnerWithThingID(@NonNull java.lang.String thingID, @NonNull KiiThingOwner owner, @NonNull java.lang.String password, @NonNull KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwnerWithThingID(String, KiiThingOwner, String)
Background task will be initiated to execute the task.- Parameters:
thingID
-owner
- to be registered as ownerpassword
- the thing passwordcallback
- called on completion
-
registerOwnerWithVendorThingID
public static void registerOwnerWithVendorThingID(@NonNull java.lang.String vendorThingID, @NonNull KiiThingOwner owner, @NonNull java.lang.String password, @NonNull KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwnerWithVendorThingID(String, KiiThingOwner, String)
Background task will be initiated to execute the task.- Parameters:
vendorThingID
-owner
- to be registered as ownerpassword
- the thing passwordcallback
- called on completion
-
disabled
public boolean disabled()
Return true if the thing is disabled, false otherwise. Callrefresh()
orrefresh(KiiCallback)
prior calling this method to get correct status.
-
register
@WorkerThread @NonNull public static KiiThing register(@NonNull java.lang.String vendorThingID, @NonNull java.lang.String password, @Nullable java.lang.String thingType, @Nullable ThingFields thingFields) throws java.io.IOException, BadRequestException, ConflictException, UndefinedException, UnauthorizedException, ForbiddenException, NotFoundException
Register thing in Kii Cloud.
This api can be executed without login user.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
vendorThingID
- thing identifier given by thing vendor.password
- thing password.thingType
- thing type.thingFields
- additional information about the thing to be registered.- Returns:
- KiiThing instance
- Throws:
java.lang.IllegalArgumentException
java.io.IOException
BadRequestException
ConflictException
UndefinedException
NotFoundException
ForbiddenException
UnauthorizedException
- See Also:
register(String, String, String, ThingFields, KiiCallback)
-
refresh
@WorkerThread public void refresh() throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Refresh thing. Retrieve the latest information of the Thing.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
refresh(KiiCallback)
-
update
@WorkerThread public void update() throws java.io.IOException, BadRequestException, NotFoundException, UnauthorizedException, ForbiddenException, ConflictException, UndefinedException
Update the thing information. You can update thing information after callingKiiBaseObject.set(String, String)
etc.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
BadRequestException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
java.lang.IllegalStateException
- when no user logged in.- See Also:
update(KiiCallback)
-
delete
@WorkerThread public void delete() throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Delete the thing. Delete the thing from Kii Cloud. It will delete bucket, topic which belongs to this thing, entity belongs to the bucket/topic and all ownership information of thing. This operation can not be reverted. Please carefully use this.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
delete(KiiCallback)
-
isOwner
@WorkerThread public boolean isOwner(@NonNull KiiThingOwner owner) throws java.io.IOException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Check if user/ group is owner of the thing.
This api is authorized by owner of the Thing.
Need user login before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
owner
- user or group can be specified.- Returns:
- true if user/ group is owner of thing. Otherwise false.
- Throws:
java.io.IOException
java.lang.IllegalArgumentException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
isOwner(KiiThingOwner, KiiCallback)
-
registerOwner
@WorkerThread public void registerOwner(@NonNull KiiThingOwner owner, @NonNull java.lang.String password) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Register owner of the thing. After the registration, owner can access the thing, buckets, objects in bucket, and topics belongs to the thing.
This api is authorized by owner of the Thing.
Need user login before execute this API.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
owner
- to be registered as ownerpassword
- the thing password- Throws:
java.lang.IllegalArgumentException
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
registerOwner(KiiThingOwner, KiiCallback)
-
unregisterOwner
@WorkerThread public void unregisterOwner(@NonNull KiiThingOwner owner) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Remove ownership of the thing from specified user/ group.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
owner
- specify user/group who owns the thing.- Throws:
java.lang.IllegalArgumentException
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
unregisterOwner(KiiThingOwner, KiiCallback)
-
disable
@WorkerThread public void disable() throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Disable the thing. After succeeded, access token published for thing is disabled. In a result, only the app administrator and owners of thing can access the thing. Used when user lost the thing and avoid using by unknown users. It doesn't throw error when the thing is already disabled.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.- See Also:
enable()
,disable(KiiCallback)
-
enable
@WorkerThread public void enable() throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Enable the thing. After succeeded, disabled thing access token will be enabled. After succeeded, If thing is registered with "persistentToken" option, token should be recovered (Access token which is used before disabling can be available). Otherwise, it does not recovered. It doesn't throw error when the thing is already enabled.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
- See Also:
disable()
,enable(KiiCallback)
-
loadWithThingID
@WorkerThread @NonNull public static KiiThing loadWithThingID(@NonNull java.lang.String thingId) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Load registered thing with thingId.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
thingId
- thingId assigned by Kii Cloud.- Returns:
- KiiThing instance.
- Throws:
java.lang.IllegalArgumentException
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.
-
loadWithVendorThingID
@WorkerThread @NonNull public static KiiThing loadWithVendorThingID(@NonNull java.lang.String vendorThingID) throws java.io.IOException, NotFoundException, UnauthorizedException, ForbiddenException, BadRequestException, ConflictException, UndefinedException
Load registered thing with vendorThingID.
This api is authorized by owner of the Thing.
Need user login who owns this Thing before execute this API.
To let users to own Thing, please callregisterOwner(KiiThingOwner)
.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
vendorThingID
- vendorThingID used for registration.- Returns:
- KiiThing instance.
- Throws:
java.lang.IllegalArgumentException
java.io.IOException
NotFoundException
UnauthorizedException
ForbiddenException
UndefinedException
ConflictException
BadRequestException
java.lang.IllegalStateException
- when no user logged in.
-
register
public static void register(@NonNull java.lang.String vendorThingID, @NonNull java.lang.String password, @Nullable java.lang.String thingType, @Nullable ThingFields thingFields, @NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofregister(String, String, String, ThingFields)
Background task will be initiated to execute the task.- Parameters:
vendorThingID
- thing identifier given by thing vendor.password
- thing password.thingType
- thing type.thingFields
- additional information about the thing to be registered.callback
- called on completion.- See Also:
register(String, String, String, ThingFields)
-
refresh
public void refresh(@NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofrefresh()
Background task will be initiated to execute the task.- Parameters:
callback
- called on completion.- See Also:
refresh()
-
update
public void update(@NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofupdate()
Background task will be initiated to execute the task. Callingrefresh()
is necessary prior calling this method.- Parameters:
callback
- called on completion.- See Also:
update()
-
delete
public void delete(@NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofdelete()
Background task will be initiated to execute the task.- Parameters:
callback
- called on completion- See Also:
delete()
-
isOwner
public void isOwner(@NonNull KiiThingOwner owner, @NonNull KiiCallback<java.lang.Boolean> callback)
Asynchronous version ofisOwner(KiiThingOwner)
Background task will be initiated to execute the task.- Parameters:
owner
- user or group can be specified.callback
- called on completion.
-
registerOwner
public void registerOwner(@NonNull KiiThingOwner owner, @NonNull java.lang.String password, @NonNull KiiCallback<KiiThingOwner> callback)
Asynchronous version ofregisterOwner(KiiThingOwner, String)
Background task will be initiated to execute the task.- Parameters:
owner
- to be registered as ownerpassword
- the thing passwordcallback
- called on completion.
-
unregisterOwner
public void unregisterOwner(@NonNull KiiThingOwner owner, @NonNull KiiCallback<KiiThingOwner> callback)
Asynchronous version ofunregisterOwner(KiiThingOwner)
Background task will be initiated to execute the task.- Parameters:
owner
- specify user/group who owns the thing.callback
- called on completion.- See Also:
unregisterOwner(KiiThingOwner)
-
disable
public void disable(@NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofdisable()
Background task will be initiated to execute the task.- Parameters:
callback
- called on completion.
-
enable
public void enable(@NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofenable()
Background task will be initiated to execute the task.- Parameters:
callback
- called on completion.
-
loadWithThingID
public static void loadWithThingID(@NonNull java.lang.String thingId, @NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofloadWithVendorThingID(String)
Background task will be initiated to execute the task.- Parameters:
thingId
- thingId assigned by Kii Cloud.callback
- called on completion.
-
loadWithVendorThingID
public static void loadWithVendorThingID(@NonNull java.lang.String vendorThingID, @NonNull KiiCallback<KiiThing> callback)
Asynchronous version ofloadWithVendorThingID(String)
Background task will be initiated to execute the task.- Parameters:
vendorThingID
- vendorThingID used for registration.callback
- called on completion.
-
bucket
@NonNull public KiiBucket bucket(@NonNull java.lang.String bucketName)
Returns bucket belongs to this thing.- Parameters:
bucketName
- name of the bucket.- Returns:
- KiiBucket belongs to this thing.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
encryptedBucket
@NonNull public KiiEncryptedBucket encryptedBucket(@NonNull java.lang.String bucketName)
Returns the KiiEncryptedBucket instance belongs to this thing.- Parameters:
bucketName
- name of the bucket- Returns:
- encrypted bucket instance.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
topic
@NonNull public KiiTopic topic(@NonNull java.lang.String name)
Get instance of thing scope topic. The topic bound to this thing.- Parameters:
name
- name of the topic.- Returns:
- KiiTopic bound to this thing.
-
listTopics
@NonNull public KiiListResult<KiiTopic> listTopics() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the list of topics in this thing scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- a list of the topics in this thing scope.
Call
KiiListResult.hasNext()
to check if there are any more result. - Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
@WorkerThread @NonNull public KiiListResult<KiiTopic> listTopics(@Nullable java.lang.String paginationKey) throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the next page of list of topics in this thing scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics()
.- Returns:
- a list of the topics in this thing scope.
- Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
public void listTopics(@NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
. A background task will be initiated to execute the task.- Parameters:
callback
- notifies events.
-
listTopics
public void listTopics(@Nullable java.lang.String paginationKey, @NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
. A background task will be initiated to execute the task.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics(KiiCallback)
.callback
- notifies events.
-
pushSubscription
@NonNull public KiiPushSubscription pushSubscription()
Get KiiPushSubscription instance of the thing. The thing will subscribe to the push service by using the returned instance.- Returns:
- KiiPushSubscription Instance of KiiPushSubscription.
- See Also:
KiiPushSubscription
-
setThingType
public void setThingType(@NonNull java.lang.String value)
Set the ThingType of this thing.- Parameters:
value
- ThingType.
-
setVendor
public void setVendor(@NonNull java.lang.String value)
Set the Vendor of this thing.- Parameters:
value
- Vendor.
-
setFirmwareVersion
public void setFirmwareVersion(@NonNull java.lang.String value)
Set the FirmwareVersion of this thing.- Parameters:
value
- FirmwareVersion.
-
setProductName
public void setProductName(@NonNull java.lang.String value)
Set the ProductName of this thing.- Parameters:
value
- ProductName.
-
setLot
public void setLot(@NonNull java.lang.String value)
Set the Lot of this thing.- Parameters:
value
- Lot.
-
setStringField1
public void setStringField1(@NonNull java.lang.String value)
Set the StringField1 of this thing. This field will be indexed for querying.- Parameters:
value
- StringField1.
-
setStringField2
public void setStringField2(@NonNull java.lang.String value)
Set the StringField2 of this thing. This field will be indexed for querying.- Parameters:
value
- StringField2.
-
setStringField3
public void setStringField3(@NonNull java.lang.String value)
Set the StringField3 of this thing. This field will be indexed for querying.- Parameters:
value
- StringField3.
-
setStringField4
public void setStringField4(@NonNull java.lang.String value)
Set the StringField4 of this thing. This field will be indexed for querying.- Parameters:
value
- StringField4.
-
setStringField5
public void setStringField5(@NonNull java.lang.String value)
Set the StringField5 of this thing. This field will be indexed for querying.- Parameters:
value
- StringField5.
-
setNumberField1
public void setNumberField1(@NonNull java.lang.Long value)
Set the NumberField1 of this thing. This field will be indexed for querying.- Parameters:
value
- NumberField1.
-
setNumberField2
public void setNumberField2(@NonNull java.lang.Long value)
Set the NumberField2 of this thing. This field will be indexed for querying.- Parameters:
value
- NumberField2.
-
setNumberField3
public void setNumberField3(@NonNull java.lang.Long value)
Set the NumberField3 of this thing. This field will be indexed for querying.- Parameters:
value
- NumberField3.
-
setNumberField4
public void setNumberField4(@NonNull java.lang.Long value)
Set the NumberField4 of this thing. This field will be indexed for querying.- Parameters:
value
- NumberField4.
-
setNumberField5
public void setNumberField5(@NonNull java.lang.Long value)
Set the NumberField5 of this thing. This field will be indexed for querying.- Parameters:
value
- NumberField5.
-
getID
@Nullable public java.lang.String getID()
Get the ThingID of this thing.- Returns:
- ThingID.
-
getCreatedTime
public long getCreatedTime()
Get the created time of this thing.- Returns:
- Created time.
-
getAccessToken
@Nullable public java.lang.String getAccessToken()
Get the AccessToken of this thing.- Returns:
- AccessToken.
-
getVendorThingID
@Nullable public java.lang.String getVendorThingID()
Get the VendorThingID of this thing.- Returns:
- VendorThingID.
-
getThingType
@Nullable public java.lang.String getThingType()
Get the ThingType of this thing.- Returns:
- ThingType. null if thing does not register ThingType.
-
getVendor
@Nullable public java.lang.String getVendor()
Get the Vendor of this thing.- Returns:
- Vendor. null if thing does not register Vendor.
-
getFirmwareVersion
@Nullable public java.lang.String getFirmwareVersion()
Get the FirmwareVersion of this thing.- Returns:
- FirmwareVersion. null if thing does not register FirmwareVersion.
-
getProductName
@Nullable public java.lang.String getProductName()
Get the ProductName of this thing.- Returns:
- ProductName. null if thing does not register ProductName.
-
getLot
@Nullable public java.lang.String getLot()
Get the Lot of this thing.- Returns:
- Lot. null if thing does not register Lot.
-
getStringField1
@Nullable public java.lang.String getStringField1()
Get the StringField1 of this thing.- Returns:
- StringField1. null if thing does not register StringField1.
-
getStringField2
@Nullable public java.lang.String getStringField2()
Get the StringField2 of this thing.- Returns:
- StringField2. null if thing does not register StringField2.
-
getStringField3
@Nullable public java.lang.String getStringField3()
Get the StringField3 of this thing.- Returns:
- StringField3. null if thing does not register StringField3.
-
getStringField4
@Nullable public java.lang.String getStringField4()
Get the StringField4 of this thing.- Returns:
- StringField4. null if thing does not register StringField4.
-
getStringField5
@Nullable public java.lang.String getStringField5()
Get the StringField5 of this thing.- Returns:
- StringField5. null if thing does not register StringField5.
-
getNumberField1
@Nullable public java.lang.Long getNumberField1()
Get the NumberField1 of this thing.- Returns:
- NumberField1. null if thing does not register NumberField1.
-
getNumberField2
@Nullable public java.lang.Long getNumberField2()
Get the NumberField2 of this thing.- Returns:
- NumberField2. null if thing does not register NumberField2.
-
getNumberField3
@Nullable public java.lang.Long getNumberField3()
Get the NumberField3 of this thing.- Returns:
- NumberField3. null if thing does not register NumberField3.
-
getNumberField4
@Nullable public java.lang.Long getNumberField4()
Get the NumberField4 of this thing.- Returns:
- NumberField4. null if thing does not register NumberField4.
-
getNumberField5
@Nullable public java.lang.Long getNumberField5()
Get the NumberField5 of this thing.- Returns:
- NumberField5. null if thing does not register NumberField5.
-
isOnline
@Nullable public java.lang.Boolean isOnline()
Get online status of the thing. Callrefresh()
orrefresh(KiiCallback)
prior calling this method to get correct status.- Returns:
- online. true if the thing is online, false otherwise. The value will be null initially until the thing is connected for the first time.
-
getOnlineStatusModifiedAt
public long getOnlineStatusModifiedAt()
Get online status modified date of the thing. Callrefresh()
orrefresh(KiiCallback)
prior calling this method to get correct value.- Returns:
- A long represents Online status modified time of this thing in milliseconds (Since January 1, 1970 00:00:00 UTC).
The value will be -1 initially until the thing is connected for the first time.
-
isValidVendorThingID
public static boolean isValidVendorThingID(@Nullable java.lang.String vendorThingID)
Checks whether the vendorThingID is valid or not.
Valid vendorThingID definition is:- Not null or empty
- Matches [a-zA-Z0-9-_\\.]{1,200}
- Parameters:
vendorThingID
- vendor thing ID.- Returns:
- true if valid otherwise false.
-
isValidThingPassword
public static boolean isValidThingPassword(@Nullable java.lang.String password)
Checks whether the thing password is valid or not.
Valid thing password definition is:- Not null or empty
- Matches ^\\p{Print}{1,200}$
- Parameters:
password
- thing password.- Returns:
- true if valid otherwise false.
-
isValidThingGenericField
public static boolean isValidThingGenericField(@NonNull java.lang.String field)
Checks whether the generic field of thing is valid or not.
Valid generic field of thing definition is:- Matches [a-zA-Z0-9-_\\. ]{0,100}
- Parameters:
field
- generic field of thing.- Returns:
- true if valid otherwise false.
-
describeContents
public int describeContents()
- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags)
- Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-
query
@NonNull @WorkerThread public static KiiThingQueryResult query(@NonNull KiiThingQuery query) throws java.io.IOException, ForbiddenException, BadRequestException, UndefinedException, ConflictException, NotFoundException, UnauthorizedException
The query operation returns a list of KiiThing that matches the query expression. Thing in the list does not contain all the property of thing. To get all the property from cloud, arefresh()
is necessary.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
query
- to be executed.- Returns:
- Throws:
java.io.IOException
ForbiddenException
BadRequestException
UndefinedException
ConflictException
NotFoundException
UnauthorizedException
-
query
public static void query(@NonNull KiiThingQuery query, @NonNull KiiCallback<KiiThingQueryResult> callback)
Asynchronous version ofquery(KiiThingQuery)
.
Background task will be initiated to execute the task.- Parameters:
query
- to be executed.callback
- called on completion.
-
-