Skip to content

Commit

Permalink
policy: make schemas conform with the new manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Jan 25, 2018
1 parent 79bcb6a commit 1ac9c83
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 133 deletions.
19 changes: 11 additions & 8 deletions gateway/src/apicast/policy/caching/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Caching policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "Caching policy",
"description":
["Configures a cache for the authentication calls against the 3scale ",
"backend. The 3scale backend can authorize (status code = 200) and deny ",
Expand All @@ -19,12 +19,15 @@
"Make sure to understand the implications of that before using this ",
"mode. It makes sense only in very specific use cases.\n",
"- None: disables caching."],
"type": "object",
"properties": {
"caching_type": {
"description": "Caching mode",
"type": "string",
"enum": ["resilient", "strict", "allow", "none"]
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"caching_type": {
"description": "Caching mode",
"type": "string",
"enum": ["resilient", "strict", "allow", "none"]
}
}
}
}
71 changes: 37 additions & 34 deletions gateway/src/apicast/policy/cors/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "CORS policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "CORS policy",
"description": "This policy enables CORS (Cross Origin Resource Sharing) request handling.",
"type": "object",
"properties": {
"allow_headers": {
"description": "Allowed headers",
"type": "array",
"items": {
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"allow_headers": {
"description": "Allowed headers",
"type": "array",
"items": {
"type": "string"
}
},
"allow_methods": {
"description": "Allowed methods",
"type": "array",
"items": {
"type": "string",
"enum": [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE",
"PATCH",
"OPTIONS",
"TRACE",
"CONNECT"
]
}
},
"allow_origin": {
"description": "Origins for which the response can be shared with",
"type": "string"
},
"allow_credentials": {
"description": "Whether the request can be made using credentials",
"type": "boolean"
}
},
"allow_methods": {
"description": "Allowed methods",
"type": "array",
"items": {
"type": "string",
"enum": [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE",
"PATCH",
"OPTIONS",
"TRACE",
"CONNECT"
]
}
},
"allow_origin": {
"description": "Origins for which the response can be shared with",
"type": "string"
},
"allow_credentials": {
"description": "Whether the request can be made using credentials",
"type": "boolean"
}
}
}
27 changes: 15 additions & 12 deletions gateway/src/apicast/policy/echo/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Echo policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "Echo policy",
"description":
["This policy prints the request back to the client and optionally sets ",
"a status code."],
"type": "object",
"properties": {
"status": {
"description": "HTTP status code to be returned",
"type": "integer"
},
"exit": {
"description": "Exit mode. 'request' interrupts the processing of the request, 'phase' only skips the rewrite phase.",
"type": "string",
"enum": ["request", "phase"]
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"status": {
"description": "HTTP status code to be returned",
"type": "integer"
},
"exit": {
"description": "Exit mode. 'request' interrupts the processing of the request, 'phase' only skips the rewrite phase.",
"type": "string",
"enum": ["request", "phase"]
}
}
}
}
59 changes: 31 additions & 28 deletions gateway/src/apicast/policy/headers/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Headers policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "Headers policy",
"description":
["This policy allows to include custom headers that will be sent to the ",
"upstream as well as modify or delete the ones included in the original ",
"request. Similarly, this policy also allows to add, modify, and delete ",
"the headers included in the response."],
"type": "object",
"definitions": {
"commands": {
"description": "List of operations to apply to the headers",
"type": "array",
"items": {
"type": "object",
"properties": {
"op": {
"description": "Operation to be applied",
"type": "string",
"enum": ["add", "set", "push"]
"version": "0.1",
"configuration": {
"type": "object",
"definitions": {
"commands": {
"description": "List of operations to apply to the headers",
"type": "array",
"items": {
"type": "object",
"properties": {
"op": {
"description": "Operation to be applied",
"type": "string",
"enum": ["add", "set", "push"]
},
"header": {
"description": "Header to be modified",
"type": "string"
},
"value": {
"description": "Value that will be added, set or pushed in the header",
"type": "string"
}
},
"header": {
"description": "Header to be modified",
"type": "string"
},
"value": {
"description": "Value that will be added, set or pushed in the header",
"type": "string"
}
},
"required": ["op", "header", "value"]
"required": ["op", "header", "value"]
}
}
},
"properties": {
"request": { "$ref": "#/definitions/commands" },
"response": { "$ref": "#/definitions/commands" }
}
},
"properties": {
"request": { "$ref": "#/definitions/commands" },
"response": { "$ref": "#/definitions/commands" }
}
}
41 changes: 22 additions & 19 deletions gateway/src/apicast/policy/upstream/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Upstream policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "Upstream policy",
"description": "This policy allows to modify the host of a request based on its path.",
"type": "object",
"properties": {
"rules": {
"description": "list of rules to be applied",
"type": "array",
"items": {
"type": "object",
"properties": {
"regex": {
"description": "regular expression to be matched",
"type": "string"
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"rules": {
"description": "list of rules to be applied",
"type": "array",
"items": {
"type": "object",
"properties": {
"regex": {
"description": "regular expression to be matched",
"type": "string"
},
"url": {
"description": "new URL in case of match",
"type": "string"
}
},
"url": {
"description": "new URL in case of match",
"type": "string"
}
},
"required": ["regex", "url"]
"required": ["regex", "url"]
}
}
}
}
Expand Down
67 changes: 35 additions & 32 deletions gateway/src/apicast/policy/url_rewriting/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "URL rewriting policy configuration",
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "URL rewriting policy",
"description":
["This policy allows to modify the path of a request. ",
"The operations supported are sub and gsub based on ngx.re.sub and ",
"ngx.re.gsub provided by OpenResty. Please check ",
"https://github.com/openresty/lua-nginx-module for more details on how ",
"to define regular expressions and learn the options supported."],
"type": "object",
"properties": {
"commands": {
"description": "List of rewriting commands to be applied",
"type": "array",
"items": {
"type": "object",
"properties": {
"op": {
"description": "Operation to be applied (sub or gsub)",
"type": "string",
"enum": ["sub", "gsub"]
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"commands": {
"description": "List of rewriting commands to be applied",
"type": "array",
"items": {
"type": "object",
"properties": {
"op": {
"description": "Operation to be applied (sub or gsub)",
"type": "string",
"enum": ["sub", "gsub"]
},
"regex": {
"description": "Regular expression to be matched",
"type": "string"
},
"replace": {
"description": "String that will replace what is matched by the regex",
"type": "string"
},
"options": {
"description": "Options that define how the regex matching is performed",
"type": "string"
},
"break": {
"description": "when set to true, if the command rewrote the URL, it will be the last one applied",
"type": "boolean"
}
},
"regex": {
"description": "Regular expression to be matched",
"type": "string"
},
"replace": {
"description": "String that will replace what is matched by the regex",
"type": "string"
},
"options": {
"description": "Options that define how the regex matching is performed",
"type": "string"
},
"break": {
"description": "when set to true, if the command rewrote the URL, it will be the last one applied",
"type": "boolean"
}
},
"required": ["op", "regex", "replace"]
"required": ["op", "regex", "replace"]
}
}
}
}
Expand Down

0 comments on commit 1ac9c83

Please sign in to comment.