Skip to content

Instantly share code, notes, and snippets.

@dhermes
Created September 24, 2018 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhermes/a4bc8adaf0048c4c69ddb671c61b10b2 to your computer and use it in GitHub Desktop.
Save dhermes/a4bc8adaf0048c4c69ddb671c61b10b2 to your computer and use it in GitHub Desktop.
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