Controlling Cameras and Devices
The Smarter AI platform libraries give you control to manage who can edit and view your cameras and devices. Each of your cameras and devices are called an Associated Endpoint and the list of all your Associated Endpoints are referred as Access Control List (ACL). This section describes how to fetch and manage associated endpoints, share access to other users and manage their roles.
Getting Associated Endpoints
Android
- To get all associated endpoints, attach the interface
Access.AssociatedEndpointsListener
to Access by callingRegisterAssociatedEndpointsListener(AssociatedEndpointsListener listener)
method ofAccess
class.AnyConnectApi.get().getAccess().RegisterAssociatedEndpointsListener(listener);
- Then call
getAssociatedEndpoints()
method ofAccess
to get all associated endpoints.Access.AccessRet getAssociatedEndpointResult = AnyConnectApi.get().getAccess().getAssociatedEndpoints();
- Calling the
getAssociatedEndpoints()
method is asynchronous and once the endpoints are fetched, they are posted in theonAclReceive(int apiStatus, AssociatedEndpoint[] endpoints)
method of the registered interface.listener = new Access.AssociatedEndpointsListener() { @Override public void onAclReceive(int apiStatus, Access.AssociatedEndpoint[] endpoints) { // apiStatus 0 for success. Error otherwise // endpoints is an array of Access.AssociatedEndpoint // See JavaDoc for Access.AssociatedEndpoint } };
An
apiStatus
and the array of the Associated Endpoints are provided through the parameter ofonAclReceive
method.
Unregister the attached interface inonAclReceive
after receiving a response.
iOS
- To get all associated endpoints, call
getAssociatedEndpoints(AssociatedEndpointCallback callback)
method ofAccess
class to register callback function.Declaration of
AssociatedEndpointCallback
is:typedef std::function<void(const int apiStatus, const std::vector<std::shared_ptr<types::AssociatedEndpoint>> associatedEndpoints)AssociatedEndpointCallback;
- Calling the
getAssociatedEndpoints(AssociatedEndpointCallback callback)
method is asynchronous and once the endpoints are fetched, you will start receiving endpoints through callback function.AccessRet getAssociatedEndpointResult = access->getAssociatedEndpoints([self](const int apiStatus, std::vector<std::shared_ptr<types::AssociatedEndpoint>> associatedEndpointList) { // apiStatus 0 for success. Error otherwise // endpoints is an array of AssociatedEndpoint // See AccessTypes.h for AssociatedEndpoint }); if (getAssociatedEndpointResult != AccessRet::OK) { // Error while fetching endpoints } else { // Got registered endpoints successfully }
An
apiStatus
and the array of the Associated Endpoints are provided through the parameter ofAssociatedEndpointCallback
method.
See the Status Codes for Access Library section for more details of apiStatus
.
Getting Presence of Associated Endpoints
Android
- To get the presence of your Associated Endpoints, prepare a String array
endpointIds
which will contain the IDs of the endpoints whose presence you want to fetch.- Then attach the interface
Access.GetPresenceListener
to Access by callingRegisterGetEndpointPresenceListener(GetPresenceListener listener)
method ofAccess
class.AnyConnectApi.get().getAccess().RegisterGetEndpointPresenceListener(getPresenceListener);
- Then call
getPresence(String[] endpointIds)
method ofAccess
by passing theendpointIds
in the parameter.AnyConnectApi.get().getAccess().getPresence(endpointIds);
- Calling
getPresence(String[] endpointIds)
is asynchronous and once the presence of the specified endpoints arrive, they are posted to theonPresenceStatus(int apiStatus, String[] presenceStatus)
method of the registered interface.getPresenceListener = new Access.GetPresenceListener() { @Override public void onPresenceStatus(int apiStatus, String[] presenceStatus) { // apiStatus 0 for success. Error otherwise // presenceStatus is an array containing presence of specified endpoints // each element of presenceStatus contains presence as endpointId=presence format } };
When the response arrives, an
apiStatus
with a list containing the presences of all specified endpoints are provided in theonPresenceStatus
method.
Iterate onpresenceStatus
to get the presence of all specified endpoints. Each element ofpresenceStatus
contains data inendpointId=Presence
format.
Presence of each endpoint can either beOnline
orOffline
. Unregister the attached interface inonPresenceStatus
after getting the response.
iOS
- To get presence of Associated Endpoints, prepare a vector
endpointIds
containing the IDs of the endpoints whose presence you want to fetch.- Then call
getPresence(const std::vector<types::Endpoint>& endpointIds, PresenceStatusCallback callback)
method ofAccess
class to register callback function.Declaration of
PresenceStatusCallback
is:typedef std::function<void(const int apiStatus, const std::map<Endpoint, PresenceStatus>& presenceStatus)> PresenceStatusCallback;
- Calling the
getPresence(const std::vector<types::Endpoint>& endpointIds, PresenceStatusCallback callback)
method is asynchronous and once the presence of your specified endpoints arrives, you will receive it through the callback function.AccessRet getPresenceOfEndpointResult = access->getPresence(endpointIds, [self] (const int apiStatus, const std::map<Endpoint, PresenceStatus>& presenceStatus) { // apiStatus 0 for success. Error otherwise }); if (getPresenceOfEndpointResult != AccessRet::OK) { //getPresence Failed }
When the response arrives, an
apiStatus
with a list containing the presences of specified endpoints are provided as a Map ofendpointID
vspresenceStatus
. Iterate on this map for getting presence of all specified endpoints. Presence of each endpoint can either beOnline
orOffline
.
See the Status Codes for Access Library section for more details of apiStatus
.
Sharing Access of Associated Endpoints
Using the Smarter AI platform library, you can share the access of your Associated Endpoints.
To share access of your endpoints with other users, you must define the role of that user.
Each role enables certain capabilities of a user to the endpoint.
Currently there are 3 types of roles in Smarter AI platform library.
The capabilities of these roles are given below.
Owner
Manage endpoint information, Manage users, Reset endpoint, StreamAdmin
Manage endpoint information, Manage users, StreamViewer
Stream
Add New User to an Endpoint
Android
- To add a new user to an endpoint, attach the
Access.AssociationCompleteListener
interface to Access by calling theRegisterAssociationCompleteListener(AssociationCompleteListener listener)
method ofAccess
class.AnyConnectApi.get().getAccess().RegisterAssociationCompleteListener(associationCompleteListener);
- Then call
associateEndpoint(String endpointId, String userEmail, PeerRole role)
method ofAccess
class by passing theendpointId
,userEmail
androle
of the user in parameter.AnyConnectApi.get().getAccess().associateEndpoint(endpointId, userEmail, Access.PeerRole.Admin);
Calling
associateEndpoint
method adds the user with specified privilege to the specified endpoint.
If you want to add someone as aViewer
, provideAccess.PeerRole.Viewer
as the last parameter of theassociateEndpoint
method.
InassociateEndpoint
method, onlyAdmin
andViewer
is applicable as aPeerRole
.
- This method call is asynchronous and once the response arrives, it's posted to the
onAssociationComplete(int status)
with astatus
in the parameter.associationCompleteListener = new Access.AssociationCompleteListener() { @Override public void onAssociationComplete(int status) { // status 0 for success. Error otherwise } };
iOS
- To add a new user to an endpoint, call
associateEndpoint(Endpoint endpointId, std::string userEmail, PeerRole role, ApiStatusCallback callback)
method of theAccess
class.AccessRet accessRet = access->associateEndpoint(endpointId, userEmail, PeerRole::Admin, [self](const int apiStatus){ // apiStatus 0 for success. Error otherwise });
Calling
associateEndpoint(Endpoint endpointId, std::string userEmail, PeerRole role, ApiStatusCallback callback)
method adds the user with specified privileges to the specified endpoint.If you want to add someone as a
Viewer
, providePeerRole::Viewer
as the parameter of theassociateEndpoint
method.
InassociateEndpoint
method, onlyAdmin
andViewer
is applicable as aPeerRole
.This method call is asynchronous and once the response arrives, you will receive it through the
ApiStatusCallback
callback method.Declaration of
ApiStatusCallback
is:typedef std::function <void(const int& status)> ApiStatusCallback;
See the Status Codes for Access Library section for more details of apiStatus
.
Get All Associated Users of an Endpoint
Android
To get all the associated users of a particular endpoint, attach the
Access.AssociatedUsersListener
interface to Access by calling theRegisterAssociatedUsersListener(AssociatedUsersListener listener)
method of theAccess
class.```java AnyConnectApi.get().getAccess().RegisterAssociatedUsersListener(associatedUsersListener); ```
Then call
getAssociatedUsers(String endpointId)
method ofAccess
withendpointId
in the parameter.AnyConnectApi.get().getAccess().getAssociatedUsers(endpointId);
Calling
getAssociatedUsers
is asynchronous and once the response arrives, it is posted to theonReceiveUsers(int apiStatus, String endpointId, Access.AssociatedUser[] users)
method of the registered interface with anapiStatus
,endpointId
and an array of theAssociatedUser
.```java associatedUsersListener = new Access.AssociatedUsersListener() { @Override public void onReceiveUsers(int apiStatus, String endpointId, Access.AssociatedUser[] users) { // apiStatus 0 for success. Error otherwise // endpointId is same as the provided endpointId of getAssociatedUsers // users is an array of Access.AssociatedUser // See Access JavaDoc for more details of Access.AssociatedUser } }; ```
Unregister the attached interface after the response has arrived in
onReceiveUsers
method.
iOS
- To get all associated users, call the
getAssociatedUsers(Endpoint endpointId, AssociatedUserCallback callback)
method of theAccess
class to register callback function.Declaration of
AssociatedUserCallback
is:typedef std::function<void(const int apiStatus, const std::vector<std::shared_ptr<types::AssociatedUser>> associatedUsers)> AssociatedUserCallback;
- Calling the
getAssociatedUsers(Endpoint endpointId, AssociatedUserCallback callback)
method is asynchronous and once the users are fetched, you will start receiving users through the callback function.AccessRet getAssociatedUsersResult = access->getAssociatedUsers(endpointID, [self] (const int apiStatus, const std::vector<std::shared_ptr<types::AssociatedUser>> associatedUsers){ // apiStatus 0 for success. Error otherwise // endpointId is same as the provided endpointId of getAssociatedUsers // users is an array of AssociatedUser // See AccessTypes.h for more details of AssociatedUser }); if (getAssociatedUsersResult != OK) { // Error while fetching AssociatedUser } else { // AssociatedUser fetch successfully }
An
apiStatus
and the array of the AssociatedAssociatedUser
are provided through the parameter of theAssociatedUserCallback
method.
See the Status Codes for Access Library section for more details of apiStatus
.
Update Role of Existing Associated User
Android
- To update the role of an existing user of a particular endpoint, attach
Access.AssociationUpdateListener
interface to Access by callingRegisterAssociationUpdateListener(AssociationUpdateListener listener)
method of theAccess
class.AnyConnectApi.get().getAccess().RegisterAssociationUpdateListener(associationUpdateListener);
- Then call the
updateAssociationRole(String endpointId, String userId, PeerRole role)
method of theAccess
class withendpointId
,userId
and the newrole
of that user.
This new role can be Admin or Viewer.AnyConnectApi.get().getAccess().updateAssociationRole(endpointId, userId, Access.PeerRole.Viewer);
- Calling
updateAssociationRole
is asynchronous and once the response arrives, it's posted to theonAssociationUpdate(int status)
with astatus
.associationUpdateListener = new Access.AssociationUpdateListener() { @Override public void onAssociationUpdate(int status) { // status 0 for success. Error otherwise } };
Unregister the attached interface after getting the response in
onAssociationUpdate
.
iOS
- To update the role of an existing user of a particular endpoint, you need to call the
updateAssociationRole(Endpoint endpointId, uint64_t userId, PeerRole role, ApiStatusCallback callback)
method of theAccess
class withendpointId
,userId
and the newrole
of that user.Declaration of
ApiStatusCallback
is:typedef std::function <void(const int& status)> ApiStatusCallback;
- Calling the
updateAssociationRole(Endpoint endpointId, uint64_t userId, PeerRole role, ApiStatusCallback callback)
method is asynchronous and once the response arrives, you will receive through callbackApiStatusCallback
method with astatus
.AccessRet accessRet = access->updateAssociationRole(endpointID, userID, PeerRole::Viewer, [self](const int apiStatus) { // status 0 for success. Error otherwise });
See the Status Codes for Access Library section for more details of apiStatus
.
Remove Associated User from Endpoint
Android
- To remove a particular user from an Associated Endpoint, attach the
Access.RemoveAssociationCompleteListener
interface to Access by calling theRegisterRemoveAssociationCompleteListener(RemoveAssociationCompleteListener listener)
method of theAccess
class.AnyConnectApi.get().getAccess().RegisterRemoveAssociationCompleteListener(removeAssociationCompleteListener);
- Then call
removeAssociation(String endpointId, String userId)
with theendpointId
of the Associated Endpoint and theuserId
of the user that needs to be removed.AnyConnectApi.get().getAccess().removeAssociation(endpointId, userId);
- Calling
removeAssociation
method is asynchronous and when the response arrives, it's posted to theonCompleteAssociationRemove(int status, String userId)
method with astatus
and theuserId
of the removed user.removeAssociationCompleteListener = new Access.RemoveAssociationCompleteListener() { @Override public void onCompleteAssociationRemove(int status, String userId) { // status 0 for success. Error otherwise // userId indicates the Id of removed user } };
Unregister the attached interface after getting the response in
onCompleteAssociationRemove
.
iOS
- To remove a particular user from an Associated Endpoint, call
removeAssociation(Endpoint endpointId, uint64_t userId, ApiStatusCallback callback)
method of theAccess
class with theendpointId
of your associated endpoint and theuserId
of the user that need to be removed.Declaration of
ApiStatusCallback
is:typedef std::function <void(const int& status)> ApiStatusCallback;
- Calling
removeAssociation(Endpoint endpointId, uint64_t userId, ApiStatusCallback callback)
method is asynchronous and when the response arrives, you will receive it through callbackApiStatusCallback
method with astatus
.AccessRet removeAssociationResult = access->removeAssociation(endpointID, userID, [self](const int apiStatus) { // status 0 for success. Error otherwise });
See the Status Codes for Access Library section for more details of apiStatus
.
Updating Endpoint Information
Android
- To update information of an Associated Endpoint, create an instance of
Access.EndpointUpdateRequest
and set the fields which needs to be update.
You can update only one field at a time.Access.EndpointUpdateRequest updateRequest = AnyConnectApi.get().getAccess().new EndpointUpdateRequest(); updateRequest.setLabel("Sweet home camera");
In the above code snippet, an instance of
Access.EndpointUpdateRequest
is created and thelabel
has been set.
- Next, attach
Access.EndpointInfoUpdateListener
interface to Access by calling theRegisterEndpointInfoUpdateListener(EndpointInfoUpdateListener listener)
method of theAccess
class.AnyConnectApi.get().getAccess().RegisterEndpointInfoUpdateListener(endpointInfoUpdateListener);
- Then, call the
updateEndpointInfo(String endpointId, EndpointUpdateRequest updateRequest)
method of theAccess
class withendpointId
andupdateRequest
in the parameter.AnyConnectApi.get().getAccess().updateEndpointInfo(endpointId, updateRequest);
- Calling
updateEndpointInfo
is asynchronous and when the response arrives, it gets posted to theonEndpointUpdated(int status)
method with astatus
.endpointInfoUpdateListener = new Access.EndpointInfoUpdateListener() { @Override public void onEndpointUpdated(int status) { // status 0 for success. Error otherwise } };
Unregister the attached interface once a response arrives in
onEndpointUpdated
.
iOS
- To update information of an Associated Endpoint, create an instance of
EndpointUpdateRequest
and set the fields which you want to update.
You can update only one field at a time.std::shared_ptr<types::EndpointUpdateRequest> endpointUpdateRequest = std::make_shared<types::EndpointUpdateRequest>(); endpointUpdateRequest->setLabel("Sweet home camera");
In the above code snippet, an instance of
EndpointUpdateRequest
is created and thelabel
has been set.
- Next call the
updateEndpointInfo(const Endpoint endpointId, const std::shared_ptr<types::EndpointUpdateRequest> endpointInfo, ApiStatusCallback callback)
method of theAccess
class to update label.Declaration of
ApiStatusCallback
is:typedef std::function <void(const int& status)> ApiStatusCallback;
- Calling the
updateEndpointInfo(const Endpoint endpointId, const std::shared_ptr<types::EndpointUpdateRequest> endpointInfo, ApiStatusCallback callback)
method is asynchronous and when the response arrives, you will receive it through the callbackApiStatusCallback
method with astatus
.AccessRet updateEndpointInfoResult = access->updateEndpointInfo(endpointID, endpointUpdateRequest, [self](const int apiStatus){ // status 0 for success. Error otherwise };
See the Status Codes for Access Library section for more details of apiStatus
.
Getting Endpoint Information Using EndpointId
Android
- To get information of a specific endpoint, attach interface
Access.EndpointInfoListener
to Access by calling theRegisterEndpointInfoListener(EndpointInfoListener listener)
method.AnyConnectApi.get().getAccess().RegisterEndpointInfoListener(endpointInfoListener);
- Then call the
getEndpointInfo(String endpointId)
method ofAccess
withendpointId
in the parameter.AnyConnectApi.get().getAccess().getEndpointInfo(endpointId);
- Calling
getEndpointInfo
is asynchronous and once the response arrives, it's posted to theonEndpointReceived(int status, Access.EndpointInfo endpointInfo)
method withstatus
andendpointInfo
in the parameter.endpointInfoListener = new Access.EndpointInfoListener() { @Override public void onEndpointReceived(int status, Access.EndpointInfo endpointInfo) { // status 0 for success. Error otherwise // endpointInfo contains all information of the endpoint // See Access JavaDoc for more information of Access.EndpointInfo } };
Unregister the attached interface once a response arrives in
onEndpointReceived
.
iOS
- To get information of a specific endpoint, call the
getEndpointInfo(const Endpoint endpointId, EndpointInfoCallback callback)
method of theAccess
class to register callback function.Declaration of
EndpointInfoCallback
is:typedef std::function<void(const int apiStatus, const std::shared_ptr<types::EndpointInfo> endpointInfo)> EndpointInfoCallback;
- Calling the
getEndpointInfo(const Endpoint endpointId, EndpointInfoCallback callback)
method is asynchronous and once the information is fetched, you will start receiving through callback function.AccessRet ret = access->getEndpointInfo(endpointID, [self](const int& apiStatus, std::shared_ptr<types::EndpointInfo> endpointInfo){ // apiStatus 0 for success. Error otherwise // See AccessTypes.h for EndpointInfo });
See the Status Codes for Access Library section for more details of apiStatus
.
Resetting Associated Endpoint
Resetting an associated endpoint will remove the endpoint for the system.
Android
To reset your endpoint, call
resetEndpoint(String endpointId)
of theAccess
class withendpointId
as the parameter.AnyConnectApi.get().getAccess().resetEndpoint(endpointId);
Calling
resetEndpoint
returns anAccessRet
enum. If resetting an endpoint is successful, thenAccessRet.OK
is returned.
iOS
To reset your endpoint, call
resetEndpoint(Endpoint endpointId)
method ofAccess
class withendpointId
as the parameter.AccessRet accessRet = access->resetEndpoint(endpointID);
Calling
resetEndpoint
method returns anAccessRet
enum. If resetting an endpoint is successful, thenAccessRet.OK
is returned.
See the Method Return Value section for more details of AccessRet
.
Updated over 2 years ago