Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Support copying slugs #52

Closed
aidanlister opened this issue Oct 4, 2014 · 2 comments
Closed

Support copying slugs #52

aidanlister opened this issue Oct 4, 2014 · 2 comments

Comments

@aidanlister
Copy link

There doesn't seem to be any way to access the slug ID:
https://devcenter.heroku.com/articles/platform-api-copying-slugs

@aidanlister
Copy link
Author

This Heroku API wrapper seems to get in the way a little. Here's a small snippet which uses Requests directly:

import requests
import json
import pprint

def doheroku(endpoint, app, command, extra_headers={}, method='get', data=None):
    base_url = 'https://api.heroku.com/'
    headers = {'Accept': 'application/vnd.heroku+json; version=3'}
    url = '%s/%s/%s/%s' % (base_url, endpoint, app, command)
    headers.update(extra_headers)
    r = getattr(requests, method)(url, headers=headers, data=data)
    return r.json()

# Fetch the most recent slug from the "app-example" app
response = doheroku('apps', 'app-example', 'releases', {'Range': 'id ..; order=asc, max=1;'})
slug_id = response[0]['slug']['id']

# Promote the head slug to "app-my-new-example"
response = doheroku('apps', 'app-my-new-example', 'releases', method='post', data={ 'slug': slug_id })
pprint.pprint(response)

This relies on your ~/.netrc usually created by heroku login.

@edmorley
Copy link
Member

This project has been deprecated for some time, and is now being sunset.

We recommend that you use the maintained https://github.com/martyzz1/heroku3.py instead.

@edmorley edmorley closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants