.ia-secondary-container
Endpoint profile is a virtual identity or "passport" of the endpoint. By filtering against the data in the profiles, endpoints may be aggregated into independently managed groups. Please review the Kaa profiling design reference for more background.
This guide will familiarize you with the basic concepts of designing endpoint profiles and programming the Kaa profiling subsystem. It is assumed that you have either set up a Kaa Sandbox, or a full-blown Kaa cluster already and that you have created a tenant and an application in Kaa.
The following diagram illustrates basic entities and data flows in scope of the endpoint profile management:
The default profile schema installed for Kaa applications is empty. In order to make use of the Kaa profiling / identity management capabilities, you should load a profile schema that reflects the application you are designing. Think about the profile schema as of a virtual identity of your client application that will later be available to you in Kaa server.
You can configure your own profile schema using the Admin UI or REST API. For the purpose of this guide we will use a fairly abstract profile schema shown below.
{ "type":"record", "name":"Profile", "namespace":"org.kaaproject.kaa.schema.sample.profile", "fields":[ { "name":"id", "type":"string" }, { "name":"os", "type":{ "type":"enum", "name":"OS", "symbols":[ "Android", "iOS", "Linux" ] } }, { "name":"os_version", "type":"string" }, { "name":"build", "type":"string" } ] }
Profile updates are reported to the endpoint SDK using a profile container. The profile related API varies depending on the target SDK platform, however the general approach is the same.
import org.kaaproject.kaa.client.Kaa; import org.kaaproject.kaa.client.KaaClient; import org.kaaproject.kaa.client.profile.ProfileContainer; import org.kaaproject.kaa.client.DesktopKaaPlatformContext; import org.kaaproject.kaa.schema.sample.profile.OS; import org.kaaproject.kaa.schema.sample.profile.Profile; // Profile is an auto-generated class based on user defined schema. Profile profile; // Desktop Kaa client initialization public void init() { // Create instance of desktop Kaa client for Kaa SDK KaaClient client = Kaa.newClient(new DesktopKaaPlatformContext(), new SimpleKaaClientStateListener()); // Sample profile profile = new Profile("id", OS.Linux, "3.17", "0.0.1-SNAPSHOT"); // Simple implementation of ProfileContainer interface that is provided by the SDK client.setProfileContainer(new ProfileContainer() { @Override public Profile getProfile() { return profile; } }); // Starts Kaa client.start(); // Update to profile variable profile.setBuild("0.0.1-SNAPSHOT"); // Report update to Kaa SDK. Force delivery of updated profile to server. client.updateProfile(); }
#include <kaa/Kaa.hpp> #include <kaa/profile/AbstractProfileContainer.hpp> #include <kaa/gen/ProfileGen.hpp> // auto-generated header using namespace kaa; // Profile container based on AbstractProfileContainer class that is provided by the SDK class BasicProfileContainer : public AbstractProfileContainer<Profile> { public: BasicProfileContainer(const Profile &profile) : profile_(profile) { } virtual Profile getProfile() { return profile_; } virtual void changeProfile(const Profile &profile) { profile_ = profile; } private: Profile profile_; }; // Kaa client initialization based on BasicProfileContainer void init() { // Create client for Kaa SDK Kaa::init(0); IKaaClient &client = Kaa::getKaaClient(); // Sample profile Profile profile; profile.id = "deviceId"; profile.os_version = "3.17"; profile.os = OS::Linux; profile.build = "0.0.1-SNAPSHOT"; // Create instance of profile container ProfileContainerPtr container(new BasicProfileContainer(profile)); // Set simple profile container to profile manager client.setProfileContainer(container); // Update method should be called to notify about changes in the profile. client.updateProfile(); // Starts Kaa Kaa::start(); }
#include <kaa_profile.h> #include <gen/kaa_profile_gen.h> // auto-generated header #define KAA_EXAMPLE_PROFILE_ID "sampleid" #define KAA_EXAMPLE_OS_VERSION "1.0" #define KAA_EXAMPLE_BUILD_INFO "3cbaf67e" kaa_context_t *kaa_context = NULL; /* Assume Kaa SDK is already initialized */ /* Create and update profile */ kaa_profile_t *profile = kaa_profile_profile_create(); profile->id = kaa_string_move_create(KAA_EXAMPLE_PROFILE_ID, NULL); profile->os = ENUM_OS_Linux; profile->os_version = kaa_string_move_create(KAA_EXAMPLE_OS_VERSION, NULL); profile->build = kaa_string_move_create(KAA_EXAMPLE_BUILD_INFO, NULL); kaa_error_t error_code = kaa_profile_manager_update_profile(kaa_context->profile_manager, profile); /* Check error code */ profile->destroy(profile);
Copyright © 2014-2015, CyberVision, Inc.