Querying for devices

Example script to query for devices

The Cloud SDK is a portal into your organization and data.

You can easily pull a list of all devices provisioned:

from formant.sdk.cloud.v1 import Client as FormantClient

if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    fclient = FormantClient()

    result = fclient.query_devices({})
    print(result["items"])

The output will be a list of device dictionaries where each dictionary looks something like this:

{'createdAt': '2021-01-18T20:32:05.470Z',
            'desiredAgentVersion': None,
            'desiredConfigurationVersion': 5,
            'disabledAt': None,
            'enabled': True,
            'followers': [],
            'id': 'c566ad6c-8ac3-42da-8052-22861749956e',
            'name': 'turtlebot.706',
            'organizationId': '0d29f656-cc1c-4b9e-baad-199cfa1fcced',
            'phoneNumber': None,
            'publicKey': '-----BEGIN PUBLIC KEY-----\n'
                         'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzWYjFgPX6r1HLWL78EnL\n'
                         'FXWnmwPCSQLUzSYjnKPxX28FnUeV5RKLmv1pbBtZcaa/XUmSUV+zTmBGvzAOC3M7\n'
                         'RXruG1CNPDDK6YABZrUpLBjB880oPxe3fWzqoeAW1SANjutw9kZQg2ATL67eUXjF\n'
                         'OYJ+Ivn5fUSwW2T79UReDO36V/dWVfvKJdHme1KrH4kWf5rpW0WEsIpK03w1pULZ\n'
                         'm1Ke6Pc8ZODw1tW4UszKTjNo0osnzZBrYXtXmRHMyElSe0BKlPITSghJKpRdio5/\n'
                         'lQedPNqC3NDIQO6NV6OCAAioXI/hHLV6w8hIhq3p//5hRwuNChL9ffJcs5ZGVrui\n'
                         'SQIDAQAB\n'
                         '-----END PUBLIC KEY-----\n',
            'scope': {'tags': {}},
            'state': {'agentVersion': '1.16.88',
                      'commandProgress': [],
                      'env': {},
                      'hwInfo': {'hwEncodingAvailable': False,
                                 'kernelInfo': {'architecture': 'x86_64',
                                                'release': '5.4.0-1029-aws',
                                                'version': '#30-Ubuntu SMP Tue '
                                                           'Oct 20 10:06:38 '
                                                           'UTC 2020'},
                                 'networkInfo': {'networks': [{'ip4': '172.31.37.102/20',
                                                               'name': 'ens5'}]},
                                 'nodeInfo': {'hostname': 'ip-172-31-37-102',
                                              'machineid': '1a5bb4bcf144dad65424a9ed5d82d969',
                                              'timezone': 'Etc/UTC'},
                                 'osInfo': {'name': 'Ubuntu 18.04.3 LTS',
                                            'release': '18.04.3',
                                            'vendor': 'ubuntu',
                                            'version': '18.04'}},
                      'onDemand': {'buffers': [{'bufferType': 'datapoint',
                                                'streams': []},
                                               {'bufferType': 's3_asset',
                                                'streams': []}]},
                      'otaEnabled': True,
                      'reportedConfiguration': {'version': 4},
                      'ros': {'topics': [{'name': '/amcl/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/amcl/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/amcl_pose',
                                          'type': 'geometry_msgs/PoseWithCovarianceStamped'},
                                         {'name': '/camera/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/camera/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/camera/rgb/camera_info',
                                          'type': 'sensor_msgs/CameraInfo'},
                                         {'name': '/camera/rgb/image_raw',
                                          'type': 'sensor_msgs/Image'},
                                         {'name': '/camera/rgb/image_raw/compressed',
                                          'type': 'sensor_msgs/CompressedImage'},
                                         {'name': '/camera/rgb/image_raw/compressed/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/camera/rgb/image_raw/compressed/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/camera/rgb/image_raw/compressedDepth',
                                          'type': 'sensor_msgs/CompressedImage'},
                                         {'name': '/camera/rgb/image_raw/compressedDepth/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/camera/rgb/image_raw/compressedDepth/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/camera/rgb/image_raw/theora',
                                          'type': 'theora_image_transport/Packet'},
                                         {'name': '/camera/rgb/image_raw/theora/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/camera/rgb/image_raw/theora/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/cancel',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/clock',
                                          'type': 'rosgraph_msgs/Clock'},
                                         {'name': '/cloud',
                                          'type': 'sensor_msgs/PointCloud2'},
                                         {'name': '/cmd_vel',
                                          'type': 'geometry_msgs/Twist'},
                                         {'name': '/diagnostics',
                                          'type': 'diagnostic_msgs/DiagnosticArray'},
                                         {'name': '/formant/command',
                                          'type': 'std_msgs/String'},
                                         {'name': '/formant/ingest',
                                          'type': 'std_msgs/Int32'},
                                         {'name': '/gazebo/link_states',
                                          'type': 'gazebo_msgs/LinkStates'},
                                         {'name': '/gazebo/model_states',
                                          'type': 'gazebo_msgs/ModelStates'},
                                         {'name': '/gazebo/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/gazebo/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/gazebo/set_link_state',
                                          'type': 'gazebo_msgs/LinkState'},
                                         {'name': '/gazebo/set_model_state',
                                          'type': 'gazebo_msgs/ModelState'},
                                         {'name': '/goal',
                                          'type': 'geometry_msgs/PoseStamped'},
                                         {'name': '/goal_one',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/goal_three',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/goal_two',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/impossible_goal',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/imu',
                                          'type': 'sensor_msgs/Imu'},
                                         {'name': '/initialpose',
                                          'type': 'geometry_msgs/PoseWithCovarianceStamped'},
                                         {'name': '/joint_states',
                                          'type': 'sensor_msgs/JointState'},
                                         {'name': '/map',
                                          'type': 'nav_msgs/OccupancyGrid'},
                                         {'name': '/map_metadata',
                                          'type': 'nav_msgs/MapMetaData'},
                                         {'name': '/move_base/DWAPlannerROS/cost_cloud',
                                          'type': 'sensor_msgs/PointCloud2'},
                                         {'name': '/move_base/DWAPlannerROS/global_plan',
                                          'type': 'nav_msgs/Path'},
                                         {'name': '/move_base/DWAPlannerROS/local_plan',
                                          'type': 'nav_msgs/Path'},
                                         {'name': '/move_base/DWAPlannerROS/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/DWAPlannerROS/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/DWAPlannerROS/trajectory_cloud',
                                          'type': 'sensor_msgs/PointCloud2'},
                                         {'name': '/move_base/NavfnROS/plan',
                                          'type': 'nav_msgs/Path'},
                                         {'name': '/move_base/cancel',
                                          'type': 'actionlib_msgs/GoalID'},
                                         {'name': '/move_base/current_goal',
                                          'type': 'geometry_msgs/PoseStamped'},
                                         {'name': '/move_base/feedback',
                                          'type': 'move_base_msgs/MoveBaseActionFeedback'},
                                         {'name': '/move_base/global_costmap/costmap',
                                          'type': 'nav_msgs/OccupancyGrid'},
                                         {'name': '/move_base/global_costmap/costmap_updates',
                                          'type': 'map_msgs/OccupancyGridUpdate'},
                                         {'name': '/move_base/global_costmap/footprint',
                                          'type': 'geometry_msgs/PolygonStamped'},
                                         {'name': '/move_base/global_costmap/inflation_layer/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/global_costmap/inflation_layer/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/global_costmap/obstacle_layer/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/global_costmap/obstacle_layer/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/global_costmap/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/global_costmap/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/global_costmap/static_layer/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/global_costmap/static_layer/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/goal',
                                          'type': 'move_base_msgs/MoveBaseActionGoal'},
                                         {'name': '/move_base/local_costmap/costmap',
                                          'type': 'nav_msgs/OccupancyGrid'},
                                         {'name': '/move_base/local_costmap/costmap_updates',
                                          'type': 'map_msgs/OccupancyGridUpdate'},
                                         {'name': '/move_base/local_costmap/footprint',
                                          'type': 'geometry_msgs/PolygonStamped'},
                                         {'name': '/move_base/local_costmap/inflation_layer/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/local_costmap/inflation_layer/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/local_costmap/obstacle_layer/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/local_costmap/obstacle_layer/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/local_costmap/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/local_costmap/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/parameter_descriptions',
                                          'type': 'dynamic_reconfigure/ConfigDescription'},
                                         {'name': '/move_base/parameter_updates',
                                          'type': 'dynamic_reconfigure/Config'},
                                         {'name': '/move_base/result',
                                          'type': 'move_base_msgs/MoveBaseActionResult'},
                                         {'name': '/move_base/status',
                                          'type': 'actionlib_msgs/GoalStatusArray'},
                                         {'name': '/move_base_simple/goal',
                                          'type': 'geometry_msgs/PoseStamped'},
                                         {'name': '/moving_to_goal',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/obstacle',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/odom',
                                          'type': 'nav_msgs/Odometry'},
                                         {'name': '/particlecloud',
                                          'type': 'geometry_msgs/PoseArray'},
                                         {'name': '/rosout',
                                          'type': 'rosgraph_msgs/Log'},
                                         {'name': '/rosout_agg',
                                          'type': 'rosgraph_msgs/Log'},
                                         {'name': '/scan',
                                          'type': 'sensor_msgs/LaserScan'},
                                         {'name': '/statusOne',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/statusTwo',
                                          'type': 'std_msgs/Bool'},
                                         {'name': '/tf',
                                          'type': 'tf2_msgs/TFMessage'},
                                         {'name': '/tf_static',
                                          'type': 'tf2_msgs/TFMessage'}]}},
            'tags': {},
            'temporaryConfigurationExpiration': None,
            'temporaryConfigurationTemplateId': None,
            'temporaryConfigurationVersion': None,
            'type': 'default',
            'updatedAt': '2021-01-19T04:15:17.102Z'},

The device object will contain all basic information, configuration, tags, and additional metadata.

Query parameters for devices

Name

Query for devices by specific names by modifying the query parameter:

fclient.query_devices({"name": "model.k.006"})

Tags

Query for devices by their tags:

fclient.query_devices({"tags": {"location": ["sf"]}})