Skip to content

Commit

Permalink
fix externalId
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Voigt committed Nov 27, 2024
1 parent ea443f6 commit 1d3b432
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion simulators/extras/ExportProfileData.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# Global variables and constants
logTimeFormat = "%Y%m%d%H%M%S_%f"
C8Y_PROFILE_GROUP = 'c8y_EventBasedSimulatorProfile'
C8Y_OEE_SIMULATOR_DEVICES_GROUP = "c8y_EventBasedSimulator"
DATA_TYPE, DEVICE_ID_LIST, CREATE_FROM, CREATE_TO, LOG_LEVEL, c8y, PASSWORD, TEST_FLAG = ArgumentsAndCredentialsHandler.HandleExportArguments()
C8Y_HEADERS, MEASUREMENTS_HEADERS = ArgumentsAndCredentialsHandler.SetupHeadersForAPIRequest(tenant_id=c8y.tenant_id, username= c8y.username, password=PASSWORD)
Expand Down
8 changes: 4 additions & 4 deletions simulators/extras/ImportData.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
timeFormat = "%Y-%m-%dT%H:%M:%S.%fZ"
logTimeFormat = "%Y%m%d%H%M%S_%f"
file_log_level = logging.DEBUG
C8Y_PROFILE_GROUP = 'c8y_EventBasedSimulatorProfile'
C8Y_OEE_SIMULATOR_DEVICES_GROUP = 'c8y_EventBasedSimulator'
json_filename_list_to_import, console_log_level, c8y, password, verifySslCertificate, TEST_FLAG, strict_mode = ArgumentsAndCredentialsHandler.HandleImportArguments()
C8Y_HEADERS, MEASUREMENTS_HEADERS = ArgumentsAndCredentialsHandler.SetupHeadersForAPIRequest(tenant_id=c8y.tenant_id, username= c8y.username, password=password)
####################################################
Expand All @@ -37,12 +37,12 @@


def GetDeviceIdByExternalId(external_id):
consoleLogger.info(f'Searching for device with ext ID {external_id}')
consoleLogger.info(f'Searching for device with ext ID {C8Y_OEE_SIMULATOR_DEVICES_GROUP}/{external_id}')
encoded_external_id = EncodeUrl(external_id)
response = session.get(f'{c8y.base_url}/identity/externalIds/{C8Y_PROFILE_GROUP}/{encoded_external_id}', headers=C8Y_HEADERS)
response = session.get(f'{c8y.base_url}/identity/externalIds/{C8Y_OEE_SIMULATOR_DEVICES_GROUP}/{encoded_external_id}', headers=C8Y_HEADERS)
if response.ok:
device_id = response.json()['managedObject']['id']
consoleLogger.info(f'Device({device_id}) has been found by its external id "{C8Y_PROFILE_GROUP}/{external_id}".')
consoleLogger.info(f'Device({device_id}) has been found by its external id "{C8Y_OEE_SIMULATOR_DEVICES_GROUP}/{external_id}".')
return device_id
consoleLogger.warning(response.json())
if strict_mode:
Expand Down

0 comments on commit 1d3b432

Please sign in to comment.