This example shows how to use the 51Degrees Cloud service to lookup
the details of a device based on a given 'native model name'.
Native model name is a string of characters that are returned from
a query to the device's OS. For more details on this, see the example below.
1 This example finds the details of devices
from the
'native model name'.
2 The native model name can be retrieved by code running on the device (For example, a mobile app).
3 For Android devices, see https://developer.android.com/reference/android/os/Build
4 For iOS devices, see https://gist.github.com/soapyigu/c99e1f45553070726f14c1bb0a54053b
5 ----------------------------------------
6 Which devices are associated
with the native model name
'SC-03L'?
7 Samsung Galaxy S10 (SC-03L)
41 from fiftyone_pipeline_core.pipelinebuilder
import PipelineBuilder
42 from fiftyone_pipeline_cloudrequestengine.cloudrequestengine
import CloudRequestEngine
43 from fiftyone_devicedetection.hardwareprofile_cloud
import HardwareProfileCloud
48 resourceKey =
"!!YOUR_RESOURCE_KEY!!" 50 if resourceKey ==
"!!YOUR_RESOURCE_KEY!!":
52 You need to create a resource key at 53 https://configure.51degrees.com and paste it into the code, 54 'replacing !!YOUR_RESOURCE_KEY!! 55 make sure to include the HardwareName, HardwareProfile and HardwareVendor 56 properties used by this example 62 requestEngineInstance = CloudRequestEngine({
63 "resourceKey": resourceKey
68 hardwareProfileEngineInstance = HardwareProfileCloud()
73 pipeline = PipelineBuilder().add(requestEngineInstance).add(hardwareProfileEngineInstance).build()
76 nativeModelAndroid =
'SC-03L' 80 flowData = pipeline.create_flowdata()
83 flowData.evidence.add(
'query.nativemodel', nativeModelAndroid)
94 print(
"Which devices are associated with the native model name: " + nativeModelAndroid)
96 for profile
in flowData.hardware.profiles:
97 hardwareVendor = profile[
"hardwarevendor"]
98 hardwareName = profile[
"hardwarename"]
99 hardwareModel = profile[
"hardwaremodel"]
101 if (hardwareVendor.has_value
and hardwareName.has_value
and hardwareModel.has_value):
102 print(hardwareVendor.value() +
" " + str(hardwareName.value()) +
" "+ hardwareModel.value())
104 print(hardwareVendor.no_value_message())