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.AssociatedEndpointsListenerto Access by callingRegisterAssociatedEndpointsListener(AssociatedEndpointsListener listener)method ofAccessclass.AnyConnectApi.get().getAccess().RegisterAssociatedEndpointsListener(listener);
- Then call
getAssociatedEndpoints()method ofAccessto 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
apiStatusand the array of the Associated Endpoints are provided through the parameter ofonAclReceivemethod.
Unregister the attached interface inonAclReceiveafter receiving a response.
iOS
- To get all associated endpoints, call
getAssociatedEndpoints(AssociatedEndpointCallback callback)method ofAccessclass to register callback function.Declaration of
AssociatedEndpointCallbackis: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
apiStatusand the array of the Associated Endpoints are provided through the parameter ofAssociatedEndpointCallbackmethod.
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
endpointIdswhich will contain the IDs of the endpoints whose presence you want to fetch.- Then attach the interface
Access.GetPresenceListenerto Access by callingRegisterGetEndpointPresenceListener(GetPresenceListener listener)method ofAccessclass.AnyConnectApi.get().getAccess().RegisterGetEndpointPresenceListener(getPresenceListener);
- Then call
getPresence(String[] endpointIds)method ofAccessby passing theendpointIdsin 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
apiStatuswith a list containing the presences of all specified endpoints are provided in theonPresenceStatusmethod.
Iterate onpresenceStatusto get the presence of all specified endpoints. Each element ofpresenceStatuscontains data inendpointId=Presenceformat.
Presence of each endpoint can either beOnlineorOffline. Unregister the attached interface inonPresenceStatusafter getting the response.
iOS
- To get presence of Associated Endpoints, prepare a vector
endpointIdscontaining the IDs of the endpoints whose presence you want to fetch.- Then call
getPresence(const std::vector<types::Endpoint>& endpointIds, PresenceStatusCallback callback)method ofAccessclass to register callback function.Declaration of
PresenceStatusCallbackis: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
apiStatuswith a list containing the presences of specified endpoints are provided as a Map ofendpointIDvspresenceStatus. Iterate on this map for getting presence of all specified endpoints. Presence of each endpoint can either beOnlineorOffline.
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.AssociationCompleteListenerinterface to Access by calling theRegisterAssociationCompleteListener(AssociationCompleteListener listener)method ofAccessclass.AnyConnectApi.get().getAccess().RegisterAssociationCompleteListener(associationCompleteListener);
- Then call
associateEndpoint(String endpointId, String userEmail, PeerRole role)method ofAccessclass by passing theendpointId,userEmailandroleof the user in parameter.AnyConnectApi.get().getAccess().associateEndpoint(endpointId, userEmail, Access.PeerRole.Admin);Calling
associateEndpointmethod adds the user with specified privilege to the specified endpoint.
If you want to add someone as aViewer, provideAccess.PeerRole.Vieweras the last parameter of theassociateEndpointmethod.
InassociateEndpointmethod, onlyAdminandVieweris applicable as aPeerRole.
- This method call is asynchronous and once the response arrives, it's posted to the
onAssociationComplete(int status)with astatusin 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 theAccessclass.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::Vieweras the parameter of theassociateEndpointmethod.
InassociateEndpointmethod, onlyAdminandVieweris applicable as aPeerRole.This method call is asynchronous and once the response arrives, you will receive it through the
ApiStatusCallbackcallback method.Declaration of
ApiStatusCallbackis: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.AssociatedUsersListenerinterface to Access by calling theRegisterAssociatedUsersListener(AssociatedUsersListener listener)method of theAccessclass.```java AnyConnectApi.get().getAccess().RegisterAssociatedUsersListener(associatedUsersListener); ```Then call
getAssociatedUsers(String endpointId)method ofAccesswithendpointIdin the parameter.AnyConnectApi.get().getAccess().getAssociatedUsers(endpointId);Calling
getAssociatedUsersis 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,endpointIdand 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
onReceiveUsersmethod.
iOS
- To get all associated users, call the
getAssociatedUsers(Endpoint endpointId, AssociatedUserCallback callback)method of theAccessclass to register callback function.Declaration of
AssociatedUserCallbackis: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
apiStatusand the array of the AssociatedAssociatedUserare provided through the parameter of theAssociatedUserCallbackmethod.
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.AssociationUpdateListenerinterface to Access by callingRegisterAssociationUpdateListener(AssociationUpdateListener listener)method of theAccessclass.AnyConnectApi.get().getAccess().RegisterAssociationUpdateListener(associationUpdateListener);
- Then call the
updateAssociationRole(String endpointId, String userId, PeerRole role)method of theAccessclass withendpointId,userIdand the newroleof that user.
This new role can be Admin or Viewer.AnyConnectApi.get().getAccess().updateAssociationRole(endpointId, userId, Access.PeerRole.Viewer);
- Calling
updateAssociationRoleis 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 theAccessclass withendpointId,userIdand the newroleof that user.Declaration of
ApiStatusCallbackis: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 callbackApiStatusCallbackmethod 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.RemoveAssociationCompleteListenerinterface to Access by calling theRegisterRemoveAssociationCompleteListener(RemoveAssociationCompleteListener listener)method of theAccessclass.AnyConnectApi.get().getAccess().RegisterRemoveAssociationCompleteListener(removeAssociationCompleteListener);
- Then call
removeAssociation(String endpointId, String userId)with theendpointIdof the Associated Endpoint and theuserIdof the user that needs to be removed.AnyConnectApi.get().getAccess().removeAssociation(endpointId, userId);
- Calling
removeAssociationmethod is asynchronous and when the response arrives, it's posted to theonCompleteAssociationRemove(int status, String userId)method with astatusand theuserIdof 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 theAccessclass with theendpointIdof your associated endpoint and theuserIdof the user that need to be removed.Declaration of
ApiStatusCallbackis: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 callbackApiStatusCallbackmethod 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.EndpointUpdateRequestand 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.EndpointUpdateRequestis created and thelabelhas been set.
- Next, attach
Access.EndpointInfoUpdateListenerinterface to Access by calling theRegisterEndpointInfoUpdateListener(EndpointInfoUpdateListener listener)method of theAccessclass.AnyConnectApi.get().getAccess().RegisterEndpointInfoUpdateListener(endpointInfoUpdateListener);
- Then, call the
updateEndpointInfo(String endpointId, EndpointUpdateRequest updateRequest)method of theAccessclass withendpointIdandupdateRequestin the parameter.AnyConnectApi.get().getAccess().updateEndpointInfo(endpointId, updateRequest);
- Calling
updateEndpointInfois 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
EndpointUpdateRequestand 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
EndpointUpdateRequestis created and thelabelhas been set.
- Next call the
updateEndpointInfo(const Endpoint endpointId, const std::shared_ptr<types::EndpointUpdateRequest> endpointInfo, ApiStatusCallback callback)method of theAccessclass to update label.Declaration of
ApiStatusCallbackis: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 callbackApiStatusCallbackmethod 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.EndpointInfoListenerto Access by calling theRegisterEndpointInfoListener(EndpointInfoListener listener)method.AnyConnectApi.get().getAccess().RegisterEndpointInfoListener(endpointInfoListener);
- Then call the
getEndpointInfo(String endpointId)method ofAccesswithendpointIdin the parameter.AnyConnectApi.get().getAccess().getEndpointInfo(endpointId);
- Calling
getEndpointInfois asynchronous and once the response arrives, it's posted to theonEndpointReceived(int status, Access.EndpointInfo endpointInfo)method withstatusandendpointInfoin 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 theAccessclass to register callback function.Declaration of
EndpointInfoCallbackis: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 theAccessclass withendpointIdas the parameter.AnyConnectApi.get().getAccess().resetEndpoint(endpointId);Calling
resetEndpointreturns anAccessRetenum. If resetting an endpoint is successful, thenAccessRet.OKis returned.
iOS
To reset your endpoint, call
resetEndpoint(Endpoint endpointId)method ofAccessclass withendpointIdas the parameter.AccessRet accessRet = access->resetEndpoint(endpointID);Calling
resetEndpointmethod returns anAccessRetenum. If resetting an endpoint is successful, thenAccessRet.OKis returned.
See the Method Return Value section for more details of AccessRet.
Updated 3 months ago