You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

5 years ago
  1. # Cloning Checks
  2. You can clone individual checks from the "Check Details"
  3. page:
  4. ![The "Create a Copy" button](IMG_URL/create_copy.png)
  5. The "Create a Copy..." function creates a new check in the same project and copies
  6. over the following:
  7. * Name, tags, description
  8. * Schedule
  9. * Assigned notification methods
  10. The newly created check has a different ping URL, and it starts with an empty log.
  11. ## Cloning All Checks Into a New Project
  12. It is sometimes useful to clone an entire project. For example, when recreating
  13. an existing deployment in a new region. The SITE_NAME web interface does
  14. not have a function to clone an entire project, but you can clone all checks in the
  15. project relatively easily using the [Management API](../api/) calls.
  16. Below is an example using Python and the [requests](https://requests.readthedocs.io/en/master/) library:
  17. ```python
  18. import requests
  19. API_URL = "SITE_ROOT/api/v1/checks/"
  20. SOURCE_PROJECT_READONLY_KEY = "..."
  21. TARGET_PROJECT_KEY = "..."
  22. r = requests.get(API_URL, headers={"X-Api-Key": SOURCE_PROJECT_READONLY_KEY})
  23. for check in r.json()["checks"]:
  24. print("Cloning %s" % check["name"])
  25. requests.post(API_URL, json=check, headers={"X-Api-Key": TARGET_PROJECT_KEY})
  26. ```