diff --git a/tools/makeDashboardsPublic/README.md b/tools/makeDashboardsPublic/README.md new file mode 100644 index 00000000..8b33ce07 --- /dev/null +++ b/tools/makeDashboardsPublic/README.md @@ -0,0 +1,17 @@ +### makeDashboardsPublic + +- After creating a dashboard with Monaco, it may not be visible. +- The visibility of the dashboard is not defined within the JSON. There's a separate endpoint to configure the visibility of it. +- This script iterates through all dashboard in all tenants (the ones created by Monaco, so just the ones with ignacio.goldman@partner.bmw.com as the owner) +making them public. +- It's recommended to execute this script after an execution of Monaco + + +#### Get Started +1. Configure the tenants under the file *config.ini [TENANTS]* using the format described: + `tenant1 = managed-env token` + `tenant2 = saas-env token` + - You can list as many tenants as you want. + +4. Execute the script: + `python makeDashboardsPublic.py` \ No newline at end of file diff --git a/tools/makeDashboardsPublic/config.ini b/tools/makeDashboardsPublic/config.ini new file mode 100644 index 00000000..8acaa2b2 --- /dev/null +++ b/tools/makeDashboardsPublic/config.ini @@ -0,0 +1,7 @@ +[TENANTS] +#tenant1 = https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b CN_PreProd_TOKEN +#tenant2 = https://dynatracemgd-cn.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35 CN_Prod_TOKEN +#tenant3 = https://xxu26128.live.dynatrace.com xxu26128_TOKEN +#tenant4 = https://wgv50241.live.dynatrace.com wgv50241_TOKEN +#tenant5 = https://qqk70169.live.dynatrace.com qqk70169_TOKEN +tenant6 = https://onb44935.live.dynatrace.com onb44935_TOKEN \ No newline at end of file diff --git a/tools/makeDashboardsPublic/makeDashboardPublic.py b/tools/makeDashboardsPublic/makeDashboardPublic.py new file mode 100644 index 00000000..51b5b49a --- /dev/null +++ b/tools/makeDashboardsPublic/makeDashboardPublic.py @@ -0,0 +1,90 @@ +import os, requests, time, json, sys, logging, configparser +from datetime import datetime, timedelta +from http.cookies import SimpleCookie + +def checkAPIlimit(): + global number_of_calls + print("API calls: ", str(number_of_calls+1)) + if number_of_calls == 59: + print("Sleeping") + time.sleep(60) + number_of_calls=0 + +def saveValues(): + YOUR_DT_API_URL = tenant_info.split(" ")[0].rstrip('\n') + YOUR_DT_API_TOKEN = tenant_info.split(" ")[1].rstrip('\n') + + return YOUR_DT_API_URL, YOUR_DT_API_TOKEN + +def update(): + print(headers) + print(YOUR_DT_API_URL) + r = requests.get(''.join(YOUR_DT_API_URL) + '/api/config/v1/dashboards', headers=headers, cookies=dict(cookies), verify=False); + print(r.text) + dashboards = json.loads(r.text) + i = 0 + while i/contentResources/contentResources.json* + + +#### Create configuration + +*Use case: A team wants to create a new provider breakdown rule* + +1. Configure *config.ini* file: + ``` + downloadConfig = 0 + updateConfig = 1 + ``` +2. Edit the file */data//contentResources/contentResources.json* adding the desired rule. For example: + ``` + { + "resourceName": "OneLogin (Prod)", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "customer.bmwgroup.com" + ] + } + ``` +3. Run the script: + ``` + python providerBreakdown.py + ``` + +#### Delete configuration + +1. Same process as before: + - access the JSON + - delete the target rule + - run the update \ No newline at end of file diff --git a/tools/providerBreakdown/config.ini b/tools/providerBreakdown/config.ini new file mode 100644 index 00000000..850411c2 --- /dev/null +++ b/tools/providerBreakdown/config.ini @@ -0,0 +1,14 @@ +[ENDPOINT] +endpoint = /api/config/v1/contentResources + +[ACTION] +downloadConfig = 0 +updateConfig = 1 + +[TENANTS] +#tenant1 = https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b CN_PreProd_TOKEN +#tenant2 = https://dynatracemgd-cn.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35 CN_Prod_TOKEN +tenant3 = https://xxu26128.live.dynatrace.com xxu26128_TOKEN +tenant4 = https://wgv50241.live.dynatrace.com wgv50241_TOKEN +tenant5 = https://qqk70169.live.dynatrace.com qqk70169_TOKEN +tenant6 = https://onb44935.live.dynatrace.com onb44935_TOKEN \ No newline at end of file diff --git a/tools/providerBreakdown/data/onb44935.live.dynatrace.com/contentResources/contentResources.json b/tools/providerBreakdown/data/onb44935.live.dynatrace.com/contentResources/contentResources.json new file mode 100644 index 00000000..3fed96b8 --- /dev/null +++ b/tools/providerBreakdown/data/onb44935.live.dynatrace.com/contentResources/contentResources.json @@ -0,0 +1,14 @@ +{ + "resourceProviders": [ + { + "resourceName": "Countly NA", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": null, + "domainNamePatterns": [ + "api.countly-preprod.bmwusa.com" + ] + } + ], + "resourceUrlCleanupRules": null, + "resourceTypes": null +} \ No newline at end of file diff --git a/tools/providerBreakdown/data/qqk70169.live.dynatrace.com/contentResources/contentResources.json b/tools/providerBreakdown/data/qqk70169.live.dynatrace.com/contentResources/contentResources.json new file mode 100644 index 00000000..9118856f --- /dev/null +++ b/tools/providerBreakdown/data/qqk70169.live.dynatrace.com/contentResources/contentResources.json @@ -0,0 +1,22 @@ +{ + "resourceProviders": [ + { + "resourceName": "Countly ROW", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": null, + "domainNamePatterns": [ + "api.countly-preprod.bmwgroup.com" + ] + }, + { + "resourceName": "hereapi.com - Vector Tile API", + "resourceType": "THIRD_PARTY_RESOURCES", + "brandIconUrl": "https://www.here.com/themes/custom/here_com_theme/favicon.ico", + "domainNamePatterns": [ + "vector.hereapi.com" + ] + } + ], + "resourceUrlCleanupRules": null, + "resourceTypes": null +} \ No newline at end of file diff --git a/tools/providerBreakdown/data/wgv50241.live.dynatrace.com/contentResources/contentResources.json b/tools/providerBreakdown/data/wgv50241.live.dynatrace.com/contentResources/contentResources.json new file mode 100644 index 00000000..b1212a50 --- /dev/null +++ b/tools/providerBreakdown/data/wgv50241.live.dynatrace.com/contentResources/contentResources.json @@ -0,0 +1,14 @@ +{ + "resourceProviders": [ + { + "resourceName": "Countly NA", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": null, + "domainNamePatterns": [ + "api.countly.bmwusa.com" + ] + } + ], + "resourceUrlCleanupRules": null, + "resourceTypes": null +} \ No newline at end of file diff --git a/tools/providerBreakdown/data/xxu26128.live.dynatrace.com/contentResources/contentResources.json b/tools/providerBreakdown/data/xxu26128.live.dynatrace.com/contentResources/contentResources.json new file mode 100644 index 00000000..edd18a55 --- /dev/null +++ b/tools/providerBreakdown/data/xxu26128.live.dynatrace.com/contentResources/contentResources.json @@ -0,0 +1,54 @@ +{ + "resourceProviders": [ + { + "resourceName": "OneLogin (Prod)", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "customer.bmwgroup.com" + ] + }, + { + "resourceName": "OneLogin (Int)", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "customer-i.bmwgroup.com" + ] + }, + { + "resourceName": "CoCo API", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "cocoapi.bmwgroup.com" + ] + }, + { + "resourceName": "Countly ROW", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "api.countly.bmwgroup.com" + ] + }, + { + "resourceName": "bmwgroup.com", + "resourceType": "FIRST_PARTY_RESOURCES", + "brandIconUrl": "https://empty", + "domainNamePatterns": [ + "bmwgroup.com" + ] + }, + { + "resourceName": "hereapi.com - Vector Tile API", + "resourceType": "THIRD_PARTY_RESOURCES", + "brandIconUrl": "https://www.here.com/themes/custom/here_com_theme/favicon.ico", + "domainNamePatterns": [ + "vector.hereapi.com" + ] + } + ], + "resourceUrlCleanupRules": null, + "resourceTypes": null +} \ No newline at end of file diff --git a/tools/providerBreakdown/providerBreakdown.py b/tools/providerBreakdown/providerBreakdown.py new file mode 100644 index 00000000..618ce812 --- /dev/null +++ b/tools/providerBreakdown/providerBreakdown.py @@ -0,0 +1,165 @@ +import os, requests, time, json, sys, logging, configparser +from datetime import datetime, timedelta +from http.cookies import SimpleCookie +from pathlib import Path + +def checkAPIlimit(): + global number_of_calls + print("API calls: ", str(number_of_calls+1)) + if number_of_calls == 59: + print("Sleeping") + time.sleep(60) + number_of_calls=0 + +def saveValues(): + YOUR_DT_API_URL = tenant_info.split(" ")[0].rstrip('\n') + YOUR_DT_API_TOKEN = tenant_info.split(" ")[1].rstrip('\n') + + return YOUR_DT_API_URL, YOUR_DT_API_TOKEN + + +def getList(): + print('Iterate through list? y/n') + iterate = input() + if iterate == 'y': + print('Enter the key of the object:') + jsonKey = input() + else: + jsonKey = None + return iterate, jsonKey + +def download(): + #Create /data folder + endpointLast = endpoint + if "/" in endpoint: + endpointLast = endpoint.split("/")[-1] + directory="data/"+env_id+"/"+endpointLast + Path(directory).mkdir(parents=True, exist_ok=True) + + print(''.join(YOUR_DT_API_URL) + endpoint) + r = requests.get(''.join(YOUR_DT_API_URL) + endpoint, headers=headers, cookies=dict(cookies), verify=False); + + data_json = json.loads(r.text) + iterate = False + for key in data_json.keys(): + if type(data_json[key]) is list: + if "id" in data_json[key][0]: + iterate = True + + if iterate == True: + i=0 + while i/FULL_WEB_REQUEST/.json* + + +#### Create configuration + +*Use case: ServiceA has a KeyRequestA used in the SLO dashboard. After a new deployment, the team changed the web server name of their application (ServiceA)* +*causing that Dynatrace detects the service as a new service (ServiceB). This new service doesn't have any keyRequest defined, so the SLO dashboard results incomplete* + +*To fix this situation (or others such as changes in ports), you can create service detection rules to merge services with differences in their metadata* + +*You can also use these rules to further split a service* + +1. Configure *config.ini* file: + ``` + deleteConfig = 0 + downloadConfig = 0 + updateConfig = 1 + ``` +2. Copy a rule from */data//FULL_WEB_REQUEST/* and paste it in the same folder. (**Do not change the file name, it will be automatically changed once the rule is created**) +3. Modify the rule as intended. +4. Remove the *id* from the rule and save it +5. Run the script: + ``` + python serviceDetectionApi.py + ``` +6. Check if the file has automatically changed the name and if it has automatically added an "id" key (may be at the bottom) + +#### Move configuration across tenants + +1. Configure *config.ini* file: + ``` + deleteConfig = 0 + downloadConfig = 0 + updateConfig = 1 + ``` +2. Copy the *.json* file from tenantA +3. Paste the rule into the tenant where you want to create the rule +4. Delete the *id* from the rule definition, so the script recognize that it's a new rule +5. Run the script: + ``` + python serviceDetectionApi.py + ``` + +#### Delete configuration + +1. Configure *config.ini* file: + ``` + deleteConfig = 1 + downloadConfig = 0 + updateConfig = 0 + ``` +2. Remove the file of the rule you want to delete from the folder +3. Run the script: + ``` + python serviceDetectionApi.py + ``` +4. The script will automatically compare the rules in the tenant vs the ones defined in the configuration folder. It will detect that there's one that has been deleted +from the folder and **it will ask you if you want to proceed deleting it from the tenant**. +- Press *y* or *yes* in case you want to proceed with the deletion +- Press any other key to cancel the operation \ No newline at end of file diff --git a/tools/serviceDetectionApi/config.ini b/tools/serviceDetectionApi/config.ini new file mode 100644 index 00000000..387acae5 --- /dev/null +++ b/tools/serviceDetectionApi/config.ini @@ -0,0 +1,20 @@ +[ENDPOINT] +endpoint = /api/config/v1/service/detectionRules/FULL_WEB_REQUEST + +[ACTION] +deleteConfig = 0 +downloadConfig = 1 +updateConfig = 0 + +[MC] +MC = No +Cookie = +User-Agent = + +[TENANTS] +#tenant1 = https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b CN_PreProd_TOKEN +#tenant2 = https://dynatracemgd-cn.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35 CN_Prod_TOKEN +tenant3 = https://xxu26128.live.dynatrace.com xxu26128_TOKEN +tenant4 = https://wgv50241.live.dynatrace.com wgv50241_TOKEN +tenant5 = https://qqk70169.live.dynatrace.com qqk70169_TOKEN +tenant6 = https://onb44935.live.dynatrace.com onb44935_TOKEN \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/onb44935.live.dynatrace.com/FULL_WEB_REQUEST/04562e4f-667b-4a9d-8e93-fa10e919e3f5.json b/tools/serviceDetectionApi/data/onb44935.live.dynatrace.com/FULL_WEB_REQUEST/04562e4f-667b-4a9d-8e93-fa10e919e3f5.json new file mode 100644 index 00000000..614fc9b9 --- /dev/null +++ b/tools/serviceDetectionApi/data/onb44935.live.dynatrace.com/FULL_WEB_REQUEST/04562e4f-667b-4a9d-8e93-fa10e919e3f5.json @@ -0,0 +1,53 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_vehicle-service" + ], + "id": "04562e4f-667b-4a9d-8e93-fa10e919e3f5", + "name": "VehicleService - TEST", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "TEST" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "VehicleService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "VehicleService" + }, + "contextRoot": null, + "serverName": null +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/qqk70169.live.dynatrace.com/FULL_WEB_REQUEST/6f903959-0881-4671-bb26-c07d9936a303.json b/tools/serviceDetectionApi/data/qqk70169.live.dynatrace.com/FULL_WEB_REQUEST/6f903959-0881-4671-bb26-c07d9936a303.json new file mode 100644 index 00000000..3ceeaa8b --- /dev/null +++ b/tools/serviceDetectionApi/data/qqk70169.live.dynatrace.com/FULL_WEB_REQUEST/6f903959-0881-4671-bb26-c07d9936a303.json @@ -0,0 +1,53 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_vehicle-service" + ], + "id": "6f903959-0881-4671-bb26-c07d9936a303", + "name": "VehicleService - TEST", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "TEST" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "VehicleService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "VehicleService" + }, + "contextRoot": null, + "serverName": null +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json b/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json new file mode 100644 index 00000000..ca13481d --- /dev/null +++ b/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json @@ -0,0 +1,56 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_vehicle-service" + ], + "id": "9d9df32f-04be-4e81-b818-60c91c3a1cd1", + "name": "VehicleService - PROD", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "PROD" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "VehicleService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "VehicleService" + }, + "contextRoot": null, + "serverName": { + "transformations": [], + "valueOverride": "VehicleService" + } +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/cff1f368-9a66-4a69-9b49-15db54745fb3.json b/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/cff1f368-9a66-4a69-9b49-15db54745fb3.json new file mode 100644 index 00000000..dabcc5b0 --- /dev/null +++ b/tools/serviceDetectionApi/data/wgv50241.live.dynatrace.com/FULL_WEB_REQUEST/cff1f368-9a66-4a69-9b49-15db54745fb3.json @@ -0,0 +1,56 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_trip-service" + ], + "id": "cff1f368-9a66-4a69-9b49-15db54745fb3", + "name": "TripService - PROD", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "PROD" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "TripService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "TripService" + }, + "contextRoot": null, + "serverName": { + "transformations": [], + "valueOverride": "TripService" + } +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/3365a46d-7238-4193-a8e1-812f00eb336d.json b/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/3365a46d-7238-4193-a8e1-812f00eb336d.json new file mode 100644 index 00000000..68f798fa --- /dev/null +++ b/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/3365a46d-7238-4193-a8e1-812f00eb336d.json @@ -0,0 +1,56 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_trip-service" + ], + "id": "3365a46d-7238-4193-a8e1-812f00eb336d", + "name": "TripService - PROD", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "PROD" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "TripService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "TripService" + }, + "contextRoot": null, + "serverName": { + "transformations": [], + "valueOverride": "TripService" + } +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json b/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json new file mode 100644 index 00000000..ca13481d --- /dev/null +++ b/tools/serviceDetectionApi/data/xxu26128.live.dynatrace.com/FULL_WEB_REQUEST/9d9df32f-04be-4e81-b818-60c91c3a1cd1.json @@ -0,0 +1,56 @@ +{ + "type": "FULL_WEB_REQUEST", + "metadata": { + "configurationVersions": [ + 0 + ], + "clusterVersion": "1.216.107.20210505-135918" + }, + "managementZones": [ + "CD_vehicle-service" + ], + "id": "9d9df32f-04be-4e81-b818-60c91c3a1cd1", + "name": "VehicleService - PROD", + "description": "Service merging", + "enabled": true, + "conditions": [ + { + "attributeType": "PG_TAG", + "compareOperations": [ + { + "type": "TAG", + "compareKeyOnly": false, + "tags": [ + { + "context": "CONTEXTLESS", + "key": "Environment", + "value": "PROD" + } + ] + } + ] + }, + { + "attributeType": "APPLICATION_ID", + "compareOperations": [ + { + "type": "EQUALS", + "negate": false, + "ignoreCase": false, + "values": [ + "VehicleService" + ] + } + ] + } + ], + "applicationId": { + "transformations": [], + "valueOverride": "VehicleService" + }, + "contextRoot": null, + "serverName": { + "transformations": [], + "valueOverride": "VehicleService" + } +} \ No newline at end of file diff --git a/tools/serviceDetectionApi/serviceDetectionApi.py b/tools/serviceDetectionApi/serviceDetectionApi.py new file mode 100644 index 00000000..932158d2 --- /dev/null +++ b/tools/serviceDetectionApi/serviceDetectionApi.py @@ -0,0 +1,202 @@ +import os, requests, time, json, sys, logging, configparser +from datetime import datetime, timedelta +from http.cookies import SimpleCookie +from pathlib import Path + +def checkAPIlimit(): + global number_of_calls + print("API calls: ", str(number_of_calls+1)) + if number_of_calls == 59: + print("Sleeping") + time.sleep(60) + number_of_calls=0 + +def saveValues(): + YOUR_DT_API_URL = tenant_info.split(" ")[0].rstrip('\n') + YOUR_DT_API_TOKEN = tenant_info.split(" ")[1].rstrip('\n') + + return YOUR_DT_API_URL, YOUR_DT_API_TOKEN + + +def getList(): + print('Iterate through list? y/n') + iterate = input() + if iterate == 'y': + print('Enter the key of the object:') + jsonKey = input() + else: + jsonKey = None + return iterate, jsonKey + +def delete(): + endpointLast = endpoint + if "/" in endpoint: + endpointLast = endpoint.split("/")[-1] + directory="data/"+env_id+"/"+endpointLast + + print(''.join(YOUR_DT_API_URL) + endpoint) + r = requests.get(''.join(YOUR_DT_API_URL) + endpoint, headers=headers, cookies=dict(cookies), verify=False); + + data_json = json.loads(r.text) + i=0 + + while i