Copy management zones between Dynatrace environments
deprecated
This API is deprecated. Use the Settings API with the Management zones settings (builtin:management-zones
) schema instead.
This use case shows you how to use the Management zones API to copy management zones between Dynatrace environments.
The execution of REST calls is up to you—you can use any REST client or write a script, like the one, provided below.
You can also use Dynatrace API Explorer to familiarize yourself with endpoints and execute all the required requests.
Script example
This Python script saves configuration of all management zones of your environment to your computer. The folder structure reflects the API path. You can later save these configurations in a version control system and/or upload them to another Dynatrace environment.
You need Python version 3.5 or higher to use this script.
Make the following adjustments to the script:
- Replace
<YOUR_ENVIRONMENT>
with the URL of your Dynatrace environment:- Dynatrace Managed https://{your-domain}/e/{your-environment-id}
- Dynatrace SaaS https://{your-environment-id}.live.dynatrace.com
- Replace
<YOUR_API_TOKEN>
with your API token which has the Read configuration and Write configuration scopes assigned.
"""Example script for fetching given Dynatrace config list items and store them on disk."""import requests, ssl, os, sysENV = '<YOUR_ENVIRONMENT>'TOKEN = '<YOUR_API_TOKEN>'HEADERS = {'Authorization': 'Api-Token ' + TOKEN}PATH = os.getcwd()def save(path, file, content):if not os.path.isdir(PATH + path):os.makedirs(PATH + path)with open(PATH + path + "/" + file, "w", encoding='utf8') as text_file:text_file.write("%s" % content)def saveList(list_type):try:r = requests.get(ENV + '/api/config/v1/' + list_type, headers=HEADERS)print("%s response code: %d" % (list_type, r.status_code))res = r.json()for entry in res['values']:print(entry['id'])tr = requests.get(ENV + '/api/config/v1/' + list_type + '/' + entry['id'], headers=HEADERS)save('/api/config/v1/' + list_type + '/', entry['id'], tr.json())except ssl.SSLError:print("SSL Error")def main():saveList('managementZones')if __name__ == '__main__':main()