Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify relation endpoints #208

Closed
jfinkels opened this issue May 20, 2013 · 10 comments
Closed

Allow users to specify relation endpoints #208

jfinkels opened this issue May 20, 2013 · 10 comments

Comments

@jfinkels
Copy link
Owner

Create a more general framework that allows users to specify which relations will be accessible and at which endpoints. For example,

relations = {'computers': ['GET', 'POST'],
             'computers/<id>': ['GET', 'DELETE', 'PATCH'],
             'computers/<id>/accessories': ['GET']
             'friends': ['GET', 'POST']
             'friends/<id>': ['GET', 'DELETE']}
apimanager.create_api(Person, relations=relations)

which should automatically allow requests like POST /api/person/1/friends. This will require a human hours-intensive rewrite of the code as it stands right now.

@jfinkels
Copy link
Owner Author

This would supercede issue #193 and (the already implemented) #2.

@jfinkels
Copy link
Owner Author

The problem here would be that requests to /api/person/1/computers/3 won't have the include/exclude field rules.

@jfinkels
Copy link
Owner Author

Maybe a more complicated list configuration, like

# A list of three tuples: first the URL fragment, second the list of methods to allow,
# and third a list of fields to include.
relations = [
             ('computers', ['GET', 'POST'], ['id']),
             ('computers/<id>', ['GET', 'DELETE', 'PATCH'], ['id', 'make', 'model']),
             ('computers/<id>/accessories', ['GET'], None),
             ('friends', ['GET', 'POST'], ['id']),
             ('friends/<id>', ['GET', 'DELETE'], ['id', 'name', 'age'])
            ]

@klinkin
Copy link
Contributor

klinkin commented May 20, 2013

... or even more complex as there http://pythonhosted.org/dictalchemy

relations = [
             ('computers', ['GET', 'POST'], {'exclude': ['id']}),
             ('computers/<id>', ['GET', 'DELETE', 'PATCH'], {'include'=['id', 'make', 'model']}),
             ('computers/<id>/accessories', ['GET'], {'only': ['id', 'model']})
            ]

@jfinkels
Copy link
Owner Author

Remember the Zen of Python:

...
Simple is better than complex.
Complex is better than complicated.
...

@klinkin
Copy link
Contributor

klinkin commented May 20, 2013

Thx, i know ))

@jfinkels
Copy link
Owner Author

It may be nice to incorporate the conventions of dictalchemy. I will look into this.

@tom-coefficient
Copy link

@jfinkels it'd be interesting to see dictalchemy conventions work their way in

@dnordberg
Copy link
Contributor

This is what I implemented (Though with a more explicit usage API) in #234. Though with much more flexibility in defining what happens at the endpoints.

jfinkels added a commit that referenced this issue Feb 19, 2015
Before the behavior of Flask-Restless was a bit arbitrary. Now we force
it to comply with a concrete (though still changing) specification,
which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This fixes (or at least makes it much easier to fix or much easier to
mark as "won't fix") several issues, including but not limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Feb 23, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Feb 24, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 3, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 5, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 7, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 8, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
@jfinkels
Copy link
Owner Author

jfinkels commented Feb 4, 2016

We now only go to /api/person/1/parent or /api/person/1/computers/2 and no further, with CRUD semantics governed by the JSON API protocol, so this is no longer relevant.

@jfinkels jfinkels closed this as completed Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants