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": "4508cabb-d16f-4589-9f3d-d8af0d9a0201",
        "creation_timestamp": "2024-03-21T14:08:49.566076Z",
        "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": {},
                    "any_ip": {},
                    "any_asn": {},
                    "any_country": {},
                    "http_method": null,
                    "domain_matcher": null,
                    "path": {
                        "prefix_values": [],
                        "exact_values": [
                            "/register",
                            "/guest-play"
                        ],
                        "regex_values": [],
                        "suffix_values": [],
                        "transformers": [],
                        "invert_matcher": false
                    },
                    "headers": []
                }
            },
            {
                "metadata": {
                    "name": "rule-2",
                    "description": "description-2",
                    "disable": false
                },
                "spec": {
                    "bypass_rate_limiter": {},
                    "any_ip": {},
                    "any_asn": {},
                    "any_country": {},
                    "http_method": null,
                    "domain_matcher": null,
                    "path": {
                        "prefix_values": [],
                        "exact_values": [
                            "/register-v2",
                            "/guest-play-v2"
                        ],
                        "regex_values": [],
                        "suffix_values": [],
                        "transformers": [],
                        "invert_matcher": false
                    },
                    "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=_var_folders_2__8qnt6fwd5dvglr1xqq6l8b7w0000gp_T_go-build3109416560_b001_apidocs.test/host=C02FN35BMD6R/svc=S:examplesvc/site=mytestce01' '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, 21 Mar 2024 14:08:49 GMT
Vary: Accept-Encoding

{
  "metadata": {
    "name": "rate-limiter-policy-1",
    "namespace": "documentation",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "4508cabb-d16f-4589-9f3d-d8af0d9a0201",
    "creation_timestamp": "2024-03-21T14:08:49.566076Z",
    "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": {

          },
          "any_ip": {

          },
          "any_asn": {

          },
          "any_country": {

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

          },
          "any_ip": {

          },
          "any_asn": {

          },
          "any_country": {

          },
          "http_method": null,
          "domain_matcher": null,
          "path": {
            "prefix_values": [
            ],
            "exact_values": [
              "/register-v2",
              "/guest-play-v2"
            ],
            "regex_values": [
            ],
            "suffix_values": [
            ],
            "transformers": [
            ],
            "invert_matcher": false
          },
          "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
            }
          ]
        }
      }
    ]
  }
}