Created
September 24, 2018 15:47
-
-
Save dhermes/a4bc8adaf0048c4c69ddb671c61b10b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
API_URL = "https://ci.appveyor.com/api" # replace for AppVeyor Enterprise | |
API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-token | |
APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL | |
APPVEYOR_PROJECT_SLUG_OLD = "<replace>" # from AppVeyor project URL | |
APPVEYOR_PROJECT_SLUG_NEW = "<replace>" # Desired slug | |
GET_URI = "{}/projects/{}/{}/settings".format( | |
API_URL, APPVEYOR_ACCOUNT_NAME, APPVEYOR_PROJECT_SLUG_OLD | |
) | |
PUT_URI = "{}/projects".format(API_URL) | |
def main(): | |
headers = { | |
"Authorization": "Bearer {}".format(API_TOKEN), | |
"Content-type": "application/json", | |
} | |
response1 = requests.get(GET_URI, headers=headers) | |
response1.raise_for_status() | |
SETTINGS_PAYLOAD = response1.json()["settings"] | |
SETTINGS_PAYLOAD["slug"] = APPVEYOR_PROJECT_SLUG_NEW | |
response2 = requests.put(PUT_URI, json=SETTINGS_PAYLOAD, headers=headers) | |
print(response2) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment