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

Examples of creating rate_limiter_policy

Usecase:

Create rate-limiter-policy-1

Request using vesctl:

vesctl configuration create rate_limiter_policy -i rate_limiter_policy.yaml

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

RequestJSON:

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

vesctl yaml response:

ResponseJSON:

  "metadata": {
    "name": "rate-limiter-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "bb2efe4b-35ed-44d0-aeba-9dfd9571d10b",
    "creation_timestamp": "2022-07-28T12:15:07.777213256Z",
    "deletion_timestamp": null,
    "modification_timestamp": null,
    "initializers": null,
    "finalizers": [
    ],
    "tenant": "acmecorp",
    "creator_class": "examplesvc",
    "creator_id": "examplesvc",
    "object_index": 0,
    "owner_view": null,
    "labels": {
    }
  },
  "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": [
            ],
            "suffix_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": [
            ],
            "suffix_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
            }
          ]
        }
      }
    ]
  }
}```
`

Request using curl:

    


curl -X 'POST' -d '{"metadata":{"name":"rate-limiter-policy-1","namespace":"documentation"},"spec":{"server_selector":{"expressions":["geoip.ves.io/region in (US-West), deployment in (testing)"]},"rules":[{"metadata":{"name":"rule-1","description":"description-1"},"spec":{"bypass_rate_limiter":{},"path":{"exact_values":["/register","/guest-play"]}}},{"metadata":{"name":"rule-2","description":"description-2"},"spec":{"bypass_rate_limiter":{},"path":{"exact_values":["/register-v2","/guest-play-v2"]},"headers":[{"name":"Accept-Language","item":{"exact_values":["en-US"]}},{"name":"Accept-Encoding","item":{"exact_values":["gzip","deflate"]}}]}}]}}' -H 'Content-Type: application/json' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build1372770011_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: Thu, 28 Jul 2022 12:15:07 GMT Vary: Accept-Encoding

{ "metadata": { "name": "rate-limiter-policy-1", "namespace": "documentation", "labels": { }, "annotations": { }, "description": "", "disable": false }, "system_metadata": { "uid": "bb2efe4b-35ed-44d0-aeba-9dfd9571d10b", "creation_timestamp": "2022-07-28T12:15:07.777213256Z", "deletion_timestamp": null, "modification_timestamp": null, "initializers": null, "finalizers": [ ], "tenant": "acmecorp", "creator_class": "examplesvc", "creator_id": "examplesvc", "object_index": 0, "owner_view": null, "labels": { } }, "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": [
        ],
        "suffix_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": [
        ],
        "suffix_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
        }
      ]
    }
  }
]

} }