ves-io-schema-views-rate_limiter_policy-API-Create

Examples of creating ratelimiterpolicy

Usecase:

Create rate-limiter-policy-1

Request using vesctl:

vesctl configuration create rate_limiter_policy -i rate_limiter_policy.yaml

where file ratelimiterpolicy.yaml has following contents (ratelimiterpolicy.CreateRequest):

metadata:
  name: rate-limiter-policy-1
  namespace: documentation
spec:
  rules:
  - metadata:
      description: description-1
      name: rule-1
    spec:
      bypassRateLimiter: {}
      path:
        exactValues:
        - /register
        - /guest-play
  - metadata:
      description: description-2
      name: rule-2
    spec:
      bypassRateLimiter: {}
      headers:
      - item:
          exactValues:
          - en-US
        name: Accept-Language
      - item:
          exactValues:
          - gzip
          - deflate
        name: Accept-Encoding
      path:
        exactValues:
        - /register-v2
        - /guest-play-v2
  serverSelector:
    expressions:
    - geoip.ves.io/region in (US-West), deployment in (testing)

vesctl yaml response:

metadata:
  annotations: {}
  labels: {}
  name: rate-limiter-policy-1
  namespace: documentation
spec:
  rules:
  - metadata:
      description: description-1
      name: rule-1
    spec:
      bypassRateLimiter: {}
      headers: []
      path:
        exactValues:
        - /register
        - /guest-play
        prefixValues: []
        regexValues: []
        transformers: []
  - metadata:
      description: description-2
      name: rule-2
    spec:
      bypassRateLimiter: {}
      headers:
      - item:
          exactValues:
          - en-US
          regexValues: []
          transformers: []
        name: Accept-Language
      - item:
          exactValues:
          - gzip
          - deflate
          regexValues: []
          transformers: []
        name: Accept-Encoding
      path:
        exactValues:
        - /register-v2
        - /guest-play-v2
        prefixValues: []
        regexValues: []
        transformers: []
  serverSelector:
    expressions:
    - geoip.ves.io/region in (US-West), deployment in (testing)
systemMetadata:
  creationTimestamp: "2021-07-14T08:08:49.663397078Z"
  creatorClass: examplesvc
  creatorId: examplesvc
  finalizers: []
  tenant: acmecorp
  uid: 020da2a4-26d9-469e-837f-796363298f34

Request using curl:

curl -X 'POST' -d '{"metadata":{"name":"rate-limiter-policy-1","namespace":"documentation"},"spec":{"serverSelector":{"expressions":["geoip.ves.io/region in (US-West), deployment in (testing)"]},"rules":[{"metadata":{"name":"rule-1","description":"description-1"},"spec":{"bypassRateLimiter":{},"path":{"exactValues":["/register","/guest-play"]}}},{"metadata":{"name":"rule-2","description":"description-2"},"spec":{"bypassRateLimiter":{},"path":{"exactValues":["/register-v2","/guest-play-v2"]},"headers":[{"name":"Accept-Language","item":{"exactValues":["en-US"]}},{"name":"Accept-Encoding","item":{"exactValues":["gzip","deflate"]}}]}}]}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build381173587_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/rate_limiter_policys'

curl response:

HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 14 Jul 2021 08:08:49 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "rate-limiter-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "020da2a4-26d9-469e-837f-796363298f34",
    "creation_timestamp": "2021-07-14T08:08:49.663397078Z",
    "deletion_timestamp": null,
    "modification_timestamp": null,
    "initializers": null,
    "finalizers": [
    ],
    "tenant": "acmecorp",
    "creator_class": "examplesvc",
    "creator_id": "examplesvc",
    "object_index": 0,
    "owner_view": null
  },
  "spec": {
    "server_selector": {
      "expressions": [
        "geoip.ves.io/region in (US-West), deployment in (testing)"
      ]
    },
    "rules": [
      {
        "metadata": {
          "name": "rule-1",
          "description": "description-1",
          "disable": false
        },
        "spec": {
          "bypass_rate_limiter": {

          },
          "http_method": null,
          "domain_matcher": null,
          "path": {
            "prefix_values": [
            ],
            "exact_values": [
              "/register",
              "/guest-play"
            ],
            "regex_values": [
            ],
            "transformers": [
            ]
          },
          "headers": [
          ]
        }
      },
      {
        "metadata": {
          "name": "rule-2",
          "description": "description-2",
          "disable": false
        },
        "spec": {
          "bypass_rate_limiter": {

          },
          "http_method": null,
          "domain_matcher": null,
          "path": {
            "prefix_values": [
            ],
            "exact_values": [
              "/register-v2",
              "/guest-play-v2"
            ],
            "regex_values": [
            ],
            "transformers": [
            ]
          },
          "headers": [
            {
              "name": "Accept-Language",
              "item": {
                "exact_values": [
                  "en-US"
                ],
                "regex_values": [
                ],
                "transformers": [
                ]
              },
              "invert_matcher": false
            },
            {
              "name": "Accept-Encoding",
              "item": {
                "exact_values": [
                  "gzip",
                  "deflate"
                ],
                "regex_values": [
                ],
                "transformers": [
                ]
              },
              "invert_matcher": false
            }
          ]
        }
      }
    ]
  }
}