Skip to content

Commit

Permalink
feat(controller): bump API to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Oct 20, 2014
1 parent 161b673 commit 85c4d07
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 346 deletions.
4 changes: 2 additions & 2 deletions builder/templates/builder
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if [ -f Procfile ]; then
fi

# pull config from controller to be used during build
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/config"
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/config"
RESPONSE=$(curl -s -XPOST \
-H "Content-Type: application/json" \
-H "X-Deis-Builder-Auth: {{ .deis_controller_builderKey }}" \
Expand Down Expand Up @@ -161,7 +161,7 @@ RELEASE_INFO=$(echo $RELEASE_INFO | sed -e 's/\"/\\\"/g')
DOCKERFILE=$(echo $DOCKERFILE | sed -e 's/\"/\\\"/g' -e 's/ \\/ /g')

puts-step "Launching... "
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/build"
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/build"
DATA="{\"sha\":\"$SHORT_SHA\",\"receive_user\":\"$USER\",\"receive_repo\":\"$APP_NAME\",\"image\":\"$APP_NAME\",\"procfile\":\"$RELEASE_INFO\",\"dockerfile\":\"$DOCKERFILE\"}"

# notify the controller that the push was successful
Expand Down
2 changes: 1 addition & 1 deletion builder/templates/receiver
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ curl \
-H 'Content-Type: application/json' \
-H "X-Deis-Builder-Auth: {{ .deis_controller_builderKey }}" \
-d "{\"receive_user\": \"$username\", \"receive_repo\": \"$app\", \"sha\": \"$sha\", \"fingerprint\": \"$fingerprint\", \"ssh_connection\": \"$SSH_CONNECTION\", \"ssh_original_command\": \"$SSH_ORIGINAL_COMMAND\"}" \
--silent http://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/push >/dev/null
--silent http://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/push >/dev/null
70 changes: 35 additions & 35 deletions client/deis.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def apps_create(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', '/api/apps',
response = self._dispatch('post', '/v1/apps',
json.dumps(body))
finally:
progress.cancel()
Expand Down Expand Up @@ -503,7 +503,7 @@ def apps_destroy(self, args):
progress = TextProgress()
progress.start()
before = time.time()
response = self._dispatch('delete', "/api/apps/{}".format(app))
response = self._dispatch('delete', "/v1/apps/{}".format(app))
finally:
progress.cancel()
progress.join()
Expand All @@ -528,7 +528,7 @@ def apps_list(self, args):
Usage: deis apps:list
"""
response = self._dispatch('get', '/api/apps')
response = self._dispatch('get', '/v1/apps')
if response.status_code == requests.codes.ok: # @UndefinedVariable
data = response.json()
self._logger.info('=== Apps')
Expand All @@ -550,7 +550,7 @@ def apps_info(self, args):
app = args.get('--app')
if not app:
app = self._session.app
response = self._dispatch('get', "/api/apps/{}".format(app))
response = self._dispatch('get', "/v1/apps/{}".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._logger.info("=== {} Application".format(app))
self._logger.info(json.dumps(response.json(), indent=2) + '\n')
Expand All @@ -574,7 +574,7 @@ def apps_open(self, args):
if not app:
app = self._session.app
# TODO: replace with a single API call to apps endpoint
response = self._dispatch('get', "/api/apps/{}".format(app))
response = self._dispatch('get', "/v1/apps/{}".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
url = response.json()['url']
# use the OS's default handler to open this URL
Expand All @@ -597,7 +597,7 @@ def apps_logs(self, args):
if not app:
app = self._session.app
response = self._dispatch('get',
"/api/apps/{}/logs".format(app))
"/v1/apps/{}/logs".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
# strip the last newline character
for line in response.json().split('\n')[:-1]:
Expand Down Expand Up @@ -641,7 +641,7 @@ def apps_run(self, args):
app = self._session.app
body = {'command': command}
response = self._dispatch('post',
"/api/apps/{}/run".format(app),
"/v1/apps/{}/run".format(app),
json.dumps(body))
if response.status_code == requests.codes.ok: # @UndefinedVariable
rc, output = json.loads(response.content)
Expand Down Expand Up @@ -699,7 +699,7 @@ def auth_register(self, args):
email = args.get('--email')
if not email:
email = raw_input('email: ')
url = urlparse.urljoin(controller, '/api/auth/register')
url = urlparse.urljoin(controller, '/v1/auth/register')
payload = {'username': username, 'password': password, 'email': email}
response = self._session.post(url, data=payload, allow_redirects=False)
if response.status_code == requests.codes.created: # @UndefinedVariable
Expand Down Expand Up @@ -730,7 +730,7 @@ def auth_cancel(self, args):
if username:
confirm = raw_input("Cancel account \"{}\" at {}? (y/n) ".format(username, controller))
if confirm == 'y':
self._dispatch('delete', '/api/auth/cancel')
self._dispatch('delete', '/v1/auth/cancel')
self._settings['controller'] = None
self._settings['token'] = None
self._settings.save()
Expand Down Expand Up @@ -764,7 +764,7 @@ def auth_login(self, args):
password = args.get('--password')
if not password:
password = getpass('password: ')
url = urlparse.urljoin(controller, '/api/auth/login/')
url = urlparse.urljoin(controller, '/v1/auth/login/')
payload = {'username': username, 'password': password}
# post credentials to the login URL
response = self._session.post(url, data=payload, allow_redirects=False)
Expand Down Expand Up @@ -840,7 +840,7 @@ def builds_create(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/builds".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/builds".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand All @@ -863,7 +863,7 @@ def builds_list(self, args):
app = args.get('--app')
if not app:
app = self._session.app
response = self._dispatch('get', "/api/apps/{}/builds".format(app))
response = self._dispatch('get', "/v1/apps/{}/builds".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._logger.info("=== {} Builds".format(app))
data = response.json()
Expand Down Expand Up @@ -905,7 +905,7 @@ def config_list(self, args):
app = self._session.app

oneline = args.get('--oneline')
response = self._dispatch('get', "/api/apps/{}/config".format(app))
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
config = response.json()
values = config['values']
Expand Down Expand Up @@ -955,7 +955,7 @@ def config_set(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1001,7 +1001,7 @@ def config_unset(self, args):
progress = TextProgress()
progress.start()
response = self._dispatch(
'post', "/api/apps/{}/config".format(app), json.dumps(body))
'post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def config_pull(self, args):
env_dict[k] = v
except IOError:
pass
response = self._dispatch('get', "/api/apps/{}/config".format(app))
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
config = response.json()['values']
for k, v in config.items():
Expand Down Expand Up @@ -1108,7 +1108,7 @@ def domains_add(self, args):
progress = TextProgress()
progress.start()
response = self._dispatch(
'post', "/api/apps/{app}/domains".format(app=app), json.dumps(body))
'post', "/v1/apps/{app}/domains".format(app=app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def domains_remove(self, args):
progress = TextProgress()
progress.start()
response = self._dispatch(
'delete', "/api/apps/{app}/domains/{domain}".format(**locals()))
'delete', "/v1/apps/{app}/domains/{domain}".format(**locals()))
finally:
progress.cancel()
progress.join()
Expand All @@ -1164,7 +1164,7 @@ def domains_list(self, args):
if not app:
app = self._session.app
response = self._dispatch(
'get', "/api/apps/{app}/domains".format(app=app))
'get', "/v1/apps/{app}/domains".format(app=app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
domains = response.json()['results']
self._logger.info("=== {} Domains".format(app))
Expand Down Expand Up @@ -1203,7 +1203,7 @@ def limits_list(self, args):
app = args.get('--app')
if not app:
app = self._session.app
response = self._dispatch('get', "/api/apps/{}/config".format(app))
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._print_limits(app, response.json())
else:
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def limits_set(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def limits_unset(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1360,7 +1360,7 @@ def ps_list(self, args, app=None):
if not app:
app = self._session.app
response = self._dispatch('get',
"/api/apps/{}/containers".format(app))
"/v1/apps/{}/containers".format(app))
if response.status_code != requests.codes.ok: # @UndefinedVariable
raise ResponseError(response)
processes = response.json()
Expand Down Expand Up @@ -1405,7 +1405,7 @@ def ps_scale(self, args):
progress.start()
before = time.time()
response = self._dispatch('post',
"/api/apps/{}/scale".format(app),
"/v1/apps/{}/scale".format(app),
json.dumps(body))
finally:
progress.cancel()
Expand Down Expand Up @@ -1443,7 +1443,7 @@ def tags_list(self, args):
app = args.get('--app')
if not app:
app = self._session.app
response = self._dispatch('get', "/api/apps/{}/config".format(app))
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._print_tags(app, response.json())
else:
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def tags_set(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1514,7 +1514,7 @@ def tags_unset(self, args):
try:
progress = TextProgress()
progress.start()
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
finally:
progress.cancel()
progress.join()
Expand Down Expand Up @@ -1575,7 +1575,7 @@ def keys_add(self, args):
}
sys.stdout.write("Uploading {} to Deis...".format(selected_key.id))
sys.stdout.flush()
response = self._dispatch('post', '/api/keys', json.dumps(body))
response = self._dispatch('post', '/v1/keys', json.dumps(body))
if response.status_code == requests.codes.created: # @UndefinedVariable
self._logger.info('done')
else:
Expand Down Expand Up @@ -1629,7 +1629,7 @@ def keys_list(self, args):
Usage: deis keys:list
"""
response = self._dispatch('get', '/api/keys')
response = self._dispatch('get', '/v1/keys')
if response.status_code == requests.codes.ok: # @UndefinedVariable
data = response.json()
if data['count'] == 0:
Expand All @@ -1656,7 +1656,7 @@ def keys_remove(self, args):
key = args.get('<key>')
sys.stdout.write("Removing {} SSH Key... ".format(key))
sys.stdout.flush()
response = self._dispatch('delete', "/api/keys/{}".format(key))
response = self._dispatch('delete', "/v1/keys/{}".format(key))
if response.status_code == requests.codes.no_content: # @UndefinedVariable
self._logger.info('done')
else:
Expand Down Expand Up @@ -1771,10 +1771,10 @@ def _parse_perms_args(self, args):
admin = args.get('--admin')
if admin:
app = None
url = '/api/admin/perms'
url = '/v1/admin/perms'
else:
app = app[0] or self._session.app
url = "/api/apps/{}/perms".format(app)
url = "/v1/apps/{}/perms".format(app)
return app, url

def releases(self, args):
Expand Down Expand Up @@ -1810,7 +1810,7 @@ def releases_info(self, args):
if not app:
app = self._session.app
response = self._dispatch(
'get', "/api/apps/{app}/releases/{version}".format(**locals()))
'get', "/v1/apps/{app}/releases/{version}".format(**locals()))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._logger.info(json.dumps(response.json(), indent=2))
else:
Expand All @@ -1829,7 +1829,7 @@ def releases_list(self, args):
app = args.get('--app')
if not app:
app = self._session.app
response = self._dispatch('get', "/api/apps/{app}/releases".format(**locals()))
response = self._dispatch('get', "/v1/apps/{app}/releases".format(**locals()))
if response.status_code == requests.codes.ok: # @UndefinedVariable
self._logger.info("=== {} Releases".format(app))
data = response.json()
Expand Down Expand Up @@ -1863,7 +1863,7 @@ def releases_rollback(self, args):
body = {'version': int(version)}
else:
body = {}
url = "/api/apps/{app}/releases/rollback".format(**locals())
url = "/v1/apps/{app}/releases/rollback".format(**locals())
if version:
sys.stdout.write('Rolling back to v{version}... '.format(**locals()))
else:
Expand Down
6 changes: 3 additions & 3 deletions controller/api/tests/test_api_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_x_deis_version_header_good(self):
Test that when the version header is sent, the request is accepted.
"""
response = self.client.get(
'/api/apps',
'/v1/apps',
HTTP_X_DEIS_VERSION=__version__.rsplit('.', 1)[0],
HTTP_AUTHORIZATION='token {}'.format(self.token),
)
Expand All @@ -38,7 +38,7 @@ def test_x_deis_version_header_bad(self):
Test that when an improper version header is sent, the request is declined.
"""
response = self.client.get(
'/api/apps',
'/v1/apps',
HTTP_X_DEIS_VERSION='1234.5678',
HTTP_AUTHORIZATION='token {}'.format(self.token),
)
Expand All @@ -48,6 +48,6 @@ def test_x_deis_version_header_not_present(self):
"""
Test that when the version header is not present, the request is accepted.
"""
response = self.client.get('/api/apps',
response = self.client.get('/v1/apps',
HTTP_AUTHORIZATION='token {}'.format(self.token))
self.assertEqual(response.status_code, 200)
Loading

0 comments on commit 85c4d07

Please sign in to comment.