Skip to content

Commit

Permalink
Rename default stage v1 to api
Browse files Browse the repository at this point in the history
Based on PR discussion.
  • Loading branch information
jamesls committed Jul 27, 2017
1 parent d72302e commit 241ea14
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 41 deletions.
44 changes: 22 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ It provides:

$ chalice deploy
...
Your application is available at: https://endpoint/v1
Your application is available at: https://endpoint/api

$ curl https://endpoint/v1
$ curl https://endpoint/api
{"hello": "world"}

Up and running in less than 30 seconds.
Expand Down Expand Up @@ -176,11 +176,11 @@ directory and run ``chalice deploy``::
$ chalice deploy
...
Initiating first time deployment...
https://qxea58oupc.execute-api.us-west-2.amazonaws.com/v1/
https://qxea58oupc.execute-api.us-west-2.amazonaws.com/api/

You now have an API up and running using API Gateway and Lambda::

$ curl https://qxea58oupc.execute-api.us-west-2.amazonaws.com/v1/
$ curl https://qxea58oupc.execute-api.us-west-2.amazonaws.com/api/
{"hello": "world"}

Try making a change to the returned dictionary from the ``index()``
Expand All @@ -195,7 +195,7 @@ Here's an example of using ``httpie`` to request the root resource of the API
we just created. Note that the command name is ``http``::


$ http https://qxea58oupc.execute-api.us-west-2.amazonaws.com/v1/
$ http https://qxea58oupc.execute-api.us-west-2.amazonaws.com/api/
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 18
Expand All @@ -209,10 +209,10 @@ we just created. Note that the command name is ``http``::


Additionally, the API Gateway endpoints will be shortened to
``https://endpoint/v1/`` for brevity. Be sure to substitute
``https://endpoint/v1/`` for the actual endpoint that the ``chalice``
``https://endpoint/api/`` for brevity. Be sure to substitute
``https://endpoint/api/`` for the actual endpoint that the ``chalice``
CLI displays when you deploy your API (it will look something like
``https://abcdefg.execute-api.us-west-2.amazonaws.com/v1/``.
``https://abcdefg.execute-api.us-west-2.amazonaws.com/api/``.

Next Steps
----------
Expand Down Expand Up @@ -278,14 +278,14 @@ the ``helloworld`` directory and it will deploy your application::
Let's try it out. Note the examples below use the ``http`` command
from the ``httpie`` package. You can install this using ``pip install httpie``::

$ http https://endpoint/v1/cities/seattle
$ http https://endpoint/api/cities/seattle
HTTP/1.1 200 OK

{
"state": "WA"
}

$ http https://endpoint/v1/cities/portland
$ http https://endpoint/api/cities/portland
HTTP/1.1 200 OK

{
Expand All @@ -296,7 +296,7 @@ from the ``httpie`` package. You can install this using ``pip install httpie``:
Notice what happens if we try to request a city that's not in our
``CITIES_TO_STATE`` map::

$ http https://endpoint/v1/cities/vancouver
$ http https://endpoint/api/cities/vancouver
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
X-Cache: Error from cloudfront
Expand Down Expand Up @@ -337,12 +337,12 @@ Save this file and redeploy your changes::

$ chalice deploy
...
https://endpoint/v1/
https://endpoint/api/

Now, when you request the same URL that returned an internal
server error, you'll get back the original stack trace::

$ http https://endpoint/v1/cities/vancouver
$ http https://endpoint/api/cities/vancouver
Traceback (most recent call last):
File "/var/task/chalice/app.py", line 304, in _get_view_function_response
response = view_function(*function_args)
Expand Down Expand Up @@ -374,7 +374,7 @@ to the user. Here's the updated code:
Save and deploy these changes::

$ chalice deploy
$ http https://endpoint/v1/cities/vancouver
$ http https://endpoint/api/cities/vancouver
HTTP/1.1 400 Bad Request

{
Expand Down Expand Up @@ -418,7 +418,7 @@ Here's an example of a view function that supports PUT:
We can test this method using the ``http`` command::

$ http PUT https://endpoint/v1/resource/foo
$ http PUT https://endpoint/api/resource/foo
HTTP/1.1 200 OK

{
Expand Down Expand Up @@ -510,7 +510,7 @@ body, and retrieve the value of that body by making a subsequent
``GET`` request to the same resource. Here's an example of its usage::

# First, trying to retrieve the key will return a 404.
$ http GET https://endpoint/v1/objects/mykey
$ http GET https://endpoint/api/objects/mykey
HTTP/1.1 404 Not Found

{
Expand All @@ -519,14 +519,14 @@ body, and retrieve the value of that body by making a subsequent
}

# Next, we'll create that key by sending a PUT request.
$ echo '{"foo": "bar"}' | http PUT https://endpoint/v1/objects/mykey
$ echo '{"foo": "bar"}' | http PUT https://endpoint/api/objects/mykey
HTTP/1.1 200 OK

null

# And now we no longer get a 404, we instead get the value we previously
# put.
$ http GET https://endpoint/v1/objects/mykey
$ http GET https://endpoint/api/objects/mykey
HTTP/1.1 200 OK

{
Expand Down Expand Up @@ -567,7 +567,7 @@ Here's an example of hitting the ``/introspect`` URL. Note how we're
sending a query string as well as a custom ``X-TestHeader`` header::


$ http 'https://endpoint/v1/introspect?query1=value1&query2=value2' 'X-TestHeader: Foo'
$ http 'https://endpoint/api/introspect?query1=value1&query2=value2' 'X-TestHeader: Foo'
HTTP/1.1 200 OK

{
Expand Down Expand Up @@ -653,7 +653,7 @@ First, we've specified that we only accept the
try to send a request with ``application/json``, we'll now
get a ``415 Unsupported Media Type`` response::

$ http POST https://endpoint/v1/ states=WA states=CA --debug
$ http POST https://endpoint/api/ states=WA states=CA --debug
...
>>> requests.request(**{'allow_redirects': False,
'headers': {'Accept': 'application/json',
Expand All @@ -671,7 +671,7 @@ If we use the ``--form`` argument, we can see the
expected behavior of this view function because ``httpie`` sets the
``Content-Type`` header to ``application/x-www-form-urlencoded``::

$ http --form POST https://endpoint/v1/formtest states=WA states=CA --debug
$ http --form POST https://endpoint/api/formtest states=WA states=CA --debug
...
>>> requests.request(**{'allow_redirects': False,
'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
Expand Down Expand Up @@ -731,7 +731,7 @@ Here's an example of this:
This will result in a plain text response body::

$ http https://endpoint/v1/
$ http https://endpoint/api/
HTTP/1.1 200 OK
Content-Length: 12
Content-Type: text/plain
Expand Down
2 changes: 1 addition & 1 deletion chalice/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def index():
"""

DEFAULT_STAGE_NAME = 'dev'
DEFAULT_APIGATEWAY_STAGE_NAME = 'v1'
DEFAULT_APIGATEWAY_STAGE_NAME = 'api'


DEFAULT_LAMBDA_TIMEOUT = 60
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ It provides:

$ chalice deploy
...
Your application is available at: https://endpoint/v1
Your application is available at: https://endpoint/api

$ curl https://endpoint/v1
$ curl https://endpoint/api
{"hello": "world"}

Up and running in less than 30 seconds.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/topics/authorizers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ necessary Lambda functions for us.

Now when we try to make a request, we'll get an Unauthorized error::

$ http https://api.us-west-2.amazonaws.com/v1/
$ http https://api.us-west-2.amazonaws.com/api/
HTTP/1.1 401 Unauthorized

{
Expand All @@ -174,7 +174,7 @@ Now when we try to make a request, we'll get an Unauthorized error::

If we add the appropriate authorization header, we'll see the call succeed::

$ http https://api.us-west-2.amazonaws.com/v1/ 'Authorization: allow'
$ http https://api.us-west-2.amazonaws.com/api/ 'Authorization: allow'
HTTP/1.1 200 OK

{
Expand All @@ -199,7 +199,7 @@ If we add the appropriate authorization header, we'll see the call succeed::
"userAgent": "HTTPie/0.9.9",
"userArn": null
},
"path": "/v1/",
"path": "/api/",
"requestId": "d35d2063-56be-11e7-9ce1-dd61c24a3668",
"resourceId": "id",
"resourcePath": "/",
Expand Down
4 changes: 2 additions & 2 deletions docs/source/topics/cfn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ will be available as an output::

$ aws cloudformation describe-stacks --stack-name test-cfn-stack \
--query "Stacks[].Outputs[?OutputKey=='EndpointURL'][] | [0].OutputValue"
"https://abc29hkq0i.execute-api.us-west-2.amazonaws.com/v1/"
"https://abc29hkq0i.execute-api.us-west-2.amazonaws.com/api/"

$ http "https://abc29hkq0i.execute-api.us-west-2.amazonaws.com/v1/"
$ http "https://abc29hkq0i.execute-api.us-west-2.amazonaws.com/api/"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 18
Expand Down
6 changes: 3 additions & 3 deletions docs/source/topics/pyversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ explicitly configure which version of python you want to use. For example::
...
"Runtime":"python3.6"
...
https://rest-api-id.execute-api.us-west-2.amazonaws.com/v1/
https://rest-api-id.execute-api.us-west-2.amazonaws.com/api/


In the example above, we're using python 3.6.1 so chalice automatically
Expand Down Expand Up @@ -71,7 +71,7 @@ For example, suppose you have an existing chalice app that uses python2::
Python 2.7.12
$ chalice deploy
...
https://endpoint/v1
https://endpoint/api

To upgrade the application to use python3, create a python3 virtual environment
and redeploy. When this happens, you will be prompted to confirm the python
Expand All @@ -87,4 +87,4 @@ runtime version changing::
The python runtime will change from python2.7 to python3.6,
would you like to continue? [Y/n]: y
...
https://endpoint/v1
https://endpoint/api
4 changes: 2 additions & 2 deletions docs/source/topics/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ Here's an example for accessing query string data in a view function:
In the function above, if the user provides a ``?include-greeting=true`` in the
HTTP request, then an additional ``greeting`` key will be returned::

$ http https://endpoint/v1/users/bob
$ http https://endpoint/api/users/bob

{
"name": "bob"
}

$ http https://endpoint/v1/users/bob?include-greeting=true
$ http https://endpoint/api/users/bob?include-greeting=true

{
"greeting": "Hello, bob",
Expand Down
8 changes: 4 additions & 4 deletions docs/source/topics/stages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Let's say we have a new app::
$ cd myapp
$ chalice deploy
...
https://mmnkdi.execute-api.us-west-2.amazonaws.com/v1/
https://mmnkdi.execute-api.us-west-2.amazonaws.com/api/

We've just created our first stage, ``dev``. We can iterate on our
application and continue to run ``chalice deploy`` to deploy our code
Expand All @@ -43,15 +43,15 @@ To do this, we can run::

$ chalice deploy --stage prod
...
https://wk9fhx.execute-api.us-west-2.amazonaws.com/v1/
https://wk9fhx.execute-api.us-west-2.amazonaws.com/api/

We now have two completely separate rest APIs::

$ chalice url --stage dev
https://mmnkdi.execute-api.us-west-2.amazonaws.com/v1/
https://mmnkdi.execute-api.us-west-2.amazonaws.com/api/

$ chalice url --stage prod
https://wk9fhx.execute-api.us-west-2.amazonaws.com/v1/
https://wk9fhx.execute-api.us-west-2.amazonaws.com/api/

Additionally, we can see all our deployed values by looking
at the ``.chalice/deployed.json`` file::
Expand Down
4 changes: 2 additions & 2 deletions docs/source/topics/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ was instantiated. For example:
This view function will generate the following HTTP response::

$ http https://endpoint/v1/badrequest
$ http https://endpoint/api/badrequest
HTTP/1.1 400 Bad Request

{
Expand Down Expand Up @@ -152,7 +152,7 @@ supports PUT:
We can test this method using the ``http`` command::

$ http PUT https://endpoint/v1/resource/foo
$ http PUT https://endpoint/api/resource/foo
HTTP/1.1 200 OK

{
Expand Down

0 comments on commit 241ea14

Please sign in to comment.