Thanks for your feedback!
EDIT
O plano define o conjunto de interceptores que serão executados no API Gateway. Cada API pode ter vários planos, mas cada plano só é executado quando está vinculado a uma app ou access token.
Agrupando interceptores em um plano, você pode criar diferentes níveis de uso para suas APIs, estabelecendo políticas de fluxo distintas para cada nível. Isso oferece um controle maior sobre como diferentes tipos de usuários acessam suas APIs.
|
Embora uma API possa ter múltiplos planos para diferentes controles de fluxo, cada plano está vinculado a uma única API. Consulte a documentação de Plans para mais detalhes. |
.yaml de Plano (comando apply)apiVersion: api-management.sensedia.com/v1
kind: Plan
metadata:
timestamp: "2024-04-16T17:06:24.046-03:00"
spec:
name: Plan Sample
apiRef:
name: API Sample
version: "1.0"
description: Plan Sample
default: true
flows:
- context:
revision: all
resourceRef:
name: all
operationRef:
method: all
path: /
requestInterceptors:
- restrictAccess:
environmentRefs:
- name: Sandbox
type: Allow | Block
- rateLimit:
calls: 1000
limitBy: IP
interval: SECOND | MINUTE | HOUR | DAY | MONTH
softLimit:
enabled: true | false
percentage: 0 | 100
returnQuotaHeader: true
- log:
encryptContent: false | true
encryptParams: false | true
- logObfuscation:
location: HEADER | BODY
attribute: "lorem.ipsum"
customRegex: .+
replaceWith: "ipsum"
- header:
headers:
- name: Content-Type
type: CUSTOM
value: application/json
- xmlToJson:
forceValueAsString: true | false
- timeAllowed:
timezone: America/Sao_Paulo
hoursOfDayInUTC: 4|15
- dataObfuscation:
location: BODY
customRegex: '"cnpj":".*"'
replaceWith: '"cnpj":"**.***.***/****-**"'
- destination:
type: APP | ACCESS_TOKEN | CUSTOM
value: "123"
- httpMethod:
method: POST
responseInterceptors:
- jsonToXml: {}
- header:
headers:
- name: Content-Type
type: CUSTOM
value: text/xml
| Se não especificar nenhuma flag, o modo interativo será ativado. |
$ ssd (api-management | apim) get plan --name Plan Sample --api-name API Sample --api-version 1.0.0 # Busca um plano com formato yaml $ ssd api-management get plan --id 111 --output yaml # Busca um plano e o salva em um arquivo yaml $ ssd api-management get plan --id 111 --output yaml > plan.yaml
apply){
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://sensedia.com/cli/api-management/plan/apply",
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"enum": [
"api-management.sensedia.com/v1"
]
},
"kind": {
"type": "string",
"enum": [
"Plan"
]
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"spec": {
"additionalProperties": false,
"type": "object",
"required": [
"name",
"apiRef"
],
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"apiRef": {
"$ref": "#/$defs/apiRef"
},
"default": {
"type": "boolean"
},
"flows": {
"type": "array",
"items": {
"$ref": "#/$defs/flow"
}
}
}
}
},
"required": [
"apiVersion",
"kind",
"spec"
],
"$defs": {
"apiRef": {
"additionalProperties": false,
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"name",
"version"
]
},
"namedRef": {
"additionalProperties": false,
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
]
},
"requestInterceptor": {
"type": "object",
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"properties": {
"ipFiltering": {
"$ref": "#/$defs/ipFilteringInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"log": {
"$ref": "#/$defs/logInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"rateLimit": {
"$ref": "#/$defs/rateLimitInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"restrictAccess": {
"$ref": "#/$defs/restrictAccessInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"mock": {
"$ref": "#/$defs/mockInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"timeAllowed": {
"$ref": "#/$defs/timeAllowedInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"header": {
"$ref": "#/$defs/headerInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"destination": {
"$ref": "#/$defs/destinationInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"httpMethod": {
"$ref": "#/$defs/httpMethodInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"logObfuscation": {
"$ref": "#/$defs/logObfuscationInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"dataObfuscation": {
"$ref": "#/$defs/dataObfuscationInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"spikeArrest": {
"$ref": "#/$defs/spikeArrestInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"jsonToTxt": {
"$ref": "#/$defs/jsonToTxtInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"jsonToXml": {
"$ref": "#/$defs/jsonToXmlInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"txtToJson": {
"$ref": "#/$defs/txtToJsonInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"xmlToJson": {
"$ref": "#/$defs/xmlToJsonInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"payloadSize": {
"$ref": "#/$defs/payloadSizeInterceptor"
}
}
}
]
},
"responseInterceptor": {
"type": "object",
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"properties": {
"ipFiltering": {
"$ref": "#/$defs/ipFilteringInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"log": {
"$ref": "#/$defs/logInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"header": {
"$ref": "#/$defs/headerInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"httpMethod": {
"$ref": "#/$defs/httpMethodInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"logObfuscation": {
"$ref": "#/$defs/logObfuscationInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"dataObfuscation": {
"$ref": "#/$defs/dataObfuscationInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"jsonToTxt": {
"$ref": "#/$defs/jsonToTxtInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"jsonToXml": {
"$ref": "#/$defs/jsonToXmlInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"txtToJson": {
"$ref": "#/$defs/txtToJsonInterceptor"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"xmlToJson": {
"$ref": "#/$defs/xmlToJsonInterceptor"
}
}
}
]
},
"flow": {
"additionalProperties": false,
"type": "object",
"properties": {
"context": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"properties": {
"revision": {
"type": "string"
},
"resourceRef": {
"$ref": "#/$defs/namedRef"
},
"operationRef": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"enum": [
"GET",
"POST",
"PATCH",
"PUT",
"DELETE",
"OPTIONS",
"all"
]
},
"path": {
"type": "string"
}
},
"required": [
"method",
"path"
]
}
},
"required": [
"revision",
"resourceRef",
"operationRef"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"revision": {
"type": "number",
"format": "int"
},
"resourceRef": {
"$ref": "#/$defs/namedRef"
}
},
"required": [
"revision",
"resourceRef"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"revision": {
"type": "number",
"format": "int"
}
},
"required": [
"revision"
]
}
]
},
"requestInterceptors": {
"type": "array",
"items": {
"$ref": "#/$defs/requestInterceptor"
}
},
"responseInterceptors": {
"type": "array",
"items": {
"$ref": "#/$defs/responseInterceptor"
}
}
}
},
"ipFilteringInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"ips": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"enum": [
"Allow",
"Block"
]
}
},
"required": [
"ips",
"type"
]
},
"logInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"encryptContent": {
"type": "boolean"
},
"encryptParams": {
"type": "boolean"
}
}
},
"oauthInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"allowedGrantTypes": {
"type": "array",
"items": {
"type": "string",
"enum": [
"AuthorizationCode",
"Implicit",
"ClientCredentials",
"Password",
"JWT"
]
}
}
}
},
"rateLimitInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"calls": {
"type": "integer"
},
"limitBy": {
"type": "string",
"enum": [
"TOTAL_CALLS",
"IP"
]
},
"interval": {
"type": "string",
"enum": [
"SECOND",
"MINUTE",
"HOUR",
"DAY",
"MONTH"
]
},
"softLimit": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"percentage": {
"type": "integer"
}
}
},
"returnQuotaHeader": {
"type": "boolean"
}
},
"required": [
"calls",
"interval",
"limitBy"
]
},
"restrictAccessInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"environmentRefs": {
"type": "array",
"items": {
"$ref": "#/$defs/namedRef"
}
},
"type": {
"type": "string",
"enum": [
"Allow",
"Block"
]
}
},
"required": [
"environmentRefs",
"type"
]
},
"mockInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"headers": {
"type": "array",
"items": {
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
},
"statusCode": {
"type": "integer"
},
"body": {
"type": "string"
}
},
"required": [
"statusCode"
]
},
"timeAllowedInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"timezone": {
"type": "string"
},
"hoursOfDayInUTC": {
"type": "string"
}
},
"required": [
"timezone",
"hoursOfDayInUTC"
]
},
"headerInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"headers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"APP",
"ACCESS_TOKEN",
"CUSTOM"
]
},
"value": {
"type": "string"
}
},
"required": [
"name",
"type",
"value"
]
}
}
}
},
"destinationInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"type": "string",
"enum": [
"APP",
"ACCESS_TOKEN",
"CUSTOM"
]
},
"value": {
"type": "string"
},
"urlType": {
"type": "string",
"enum": [
"ENTIRE_URL",
"HOST"
]
}
},
"required": [
"type",
"value"
]
},
"httpMethodInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"type": "string",
"enum": [
"GET",
"POST",
"PUT",
"DELETE"
]
}
},
"required": [
"method"
]
},
"logObfuscationInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"location": {
"type": "string",
"enum": [
"HEADER",
"BODY"
]
},
"attribute": {
"type": "string"
},
"customRegex": {
"type": "string"
},
"replaceWith": {
"type": "string"
}
},
"required": [
"location",
"replaceWith"
]
},
"dataObfuscationInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"location": {
"type": "string",
"enum": [
"HEADER",
"BODY"
]
},
"attribute": {
"type": "string"
},
"customRegex": {
"type": "string"
},
"replaceWith": {
"type": "string"
}
},
"required": [
"location",
"replaceWith"
]
},
"spikeArrestInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"limit": {
"type": "integer"
},
"interval": {
"type": "string",
"enum": [
"SECOND",
"MINUTE",
"HOUR"
]
}
},
"required": [
"limit",
"interval"
]
},
"jsonToTxtInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {}
},
"jsonToXmlInterceptor": {},
"txtToJsonInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {}
},
"xmlToJsonInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"forceValueAsString": {
"type": "boolean"
}
}
},
"payloadSizeInterceptor": {
"type": "object",
"additionalProperties": false,
"properties": {
"maximumSizeKBytes": {
"type": "integer"
}
},
"required": ["maximumSizeKBytes"]
}
}
}
Share your suggestions with us!
Click here and then [+ Submit idea]