1515import logging
1616from os import makedirs
1717from enum import Enum
18- from nrfcloud_utils .cli_helpers import write_file , setup_logging
18+ from nrfcloud_utils .cli_helpers import write_file , setup_logging , USER_AGENT
1919
2020logger = logging .getLogger (__name__ )
2121
@@ -105,30 +105,31 @@ def set_dev_stage(stage = ''):
105105 return api_url
106106
107107def get_bulk_ops_result (api_key , bulk_ops_req_id ):
108- hdr = {'Authorization' : 'Bearer ' + api_key }
108+ hdr = {'Authorization' : 'Bearer ' + api_key , 'User-Agent' : USER_AGENT }
109109 req = api_url + "bulk-ops-requests/" + bulk_ops_req_id
110110 return requests .get (req , headers = hdr )
111111
112112def update_device_shadow (api_key , device_id , json_payload ):
113- hdr = {'Authorization' : 'Bearer ' + api_key }
113+ hdr = {'Authorization' : 'Bearer ' + api_key , 'User-Agent' : USER_AGENT }
114114 req = api_url + "devices/" + device_id + "/state"
115115 return requests .patch (req , json = json_payload , headers = hdr )
116116
117117def fetch_device (api_key , device_id ):
118- hdr = {'Authorization' : 'Bearer ' + api_key }
118+ hdr = {'Authorization' : 'Bearer ' + api_key , 'User-Agent' : USER_AGENT }
119119 req = api_url + "devices/" + device_id
120120 return requests .get (req , headers = hdr )
121121
122122def update_device_name (api_key , device_id , name ):
123- hdr = {'Authorization' : 'Bearer ' + api_key }
123+ hdr = {'Authorization' : 'Bearer ' + api_key , 'User-Agent' : USER_AGENT }
124124 req = api_url + "devices/" + device_id + "/name"
125125 json_payload = [name ]
126126 return requests .put (req , json = json_payload , headers = hdr )
127127
128128def onboard_device (api_key , dev_id , sub_type , tags , fw_types , cert_pem_str ):
129129 hdr = {'Authorization' : 'Bearer ' + api_key ,
130130 'content-type' : 'text/plain' ,
131- 'Accept-Encoding' : '*' }
131+ 'Accept-Encoding' : '*' ,
132+ 'User-Agent' : USER_AGENT }
132133
133134 req = api_url + "devices"
134135
@@ -139,7 +140,8 @@ def onboard_device(api_key, dev_id, sub_type, tags, fw_types, cert_pem_str):
139140def onboard_devices (api_key , csv_filepath ):
140141 hdr = {'Authorization' : 'Bearer ' + api_key ,
141142 'content-type' : 'text/csv' ,
142- 'Accept-Encoding' : '*' }
143+ 'Accept-Encoding' : '*' ,
144+ 'User-Agent' : USER_AGENT }
143145
144146 req = api_url + "devices"
145147
0 commit comments