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

[Feature] Add policies rest api #2493

Open
wants to merge 19 commits into
base: master
from

Conversation

@williamokano
Copy link

commented Sep 7, 2019

This pull request intention is to add the missing REST API endpoints for listing and managing the Tyk Gateway policies.

I've added endpoints for managing and listing policies. Modifying any policy requires reloading the policies.json file. Won't work if using Tyk Dashboard.

Method URL Payload Response Description
GET /tyk/policies nil []user.Policy Get a list of all policies
GET /tyk/policies/{polID} nil user.Policy Get a single policy by ID
POST /tyk/policies user.Policy apiModifyKeySuccess Create a policy (append to policies.json). Only works if using headless.
PUT /tyk/policies/{polID} user.Policy apiModifyKeySuccess Update an existing policy.
DELETE /tyk/policies/{polID} nil apiModifyKeySuccess Delete an existing policy

This pull request fixed the this isse #2379

williamokano added 14 commits Sep 6, 2019
Updated create policy to attempt to create policies file if not found…
…. Changed status code on create from 200 to 201

@williamokano williamokano marked this pull request as ready for review Sep 7, 2019

@williamokano williamokano changed the title [WIP] Feature/policies rest api [Feature] Add policies rest api Sep 7, 2019

@matiasinsaurralde
Copy link
Member

left a comment

Some minor changes

gateway/api.go Outdated Show resolved Hide resolved
gateway/api.go Outdated Show resolved Hide resolved
gateway/api.go Outdated Show resolved Hide resolved
williamokano added 2 commits Sep 9, 2019
@sedkis

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2019

Hi @williamokano ,
I will review and get back to you.
Thanks

@williamokano

This comment has been minimized.

Copy link
Author

commented Sep 10, 2019

@sedkis Hi, Thanks.

@williamokano williamokano requested a review from matiasinsaurralde Sep 10, 2019

@matiasinsaurralde matiasinsaurralde requested a review from sedkis Sep 11, 2019

@sedkis sedkis self-assigned this Sep 12, 2019

Added loadPolicies validation in order to avoid race condition on cha…
…nging and reading the file, leading to json decode errors since the file is not fully written yet (edge case, multiple concurrents updates).
@sedkis

This comment has been minimized.

Copy link
Contributor

commented Sep 17, 2019

It's obvious the hard work you've put into this. Thank-you for your contribution! But can't accept at this time because of the following reasons:

  • This approach only works on a single node
  • These APIs already exist in the Dashboard

Thank-you.

@williamokano

This comment has been minimized.

Copy link
Author

commented Sep 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.