ves-io-schema-protocol_policer-API-Create

Examples of creating protocol_policer

Usecase:

Create protocol-policer-1 to rate limit all TCP SYN packets

Request using vesctl:

vesctl configuration create protocol_policer -i protocol_policer.yaml

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

RequestJSON:

{"metadata":{"name":"protocol-policer-1","namespace":"system"},"spec":{"protocol_policer":[{"protocol":{"tcp":{"flags":["SYN"]}},"policer":[{"kind":"policer","name":"tcp-syn-limiter"}]}]}} `

vesctl yaml response:

ResponseJSON:

  "metadata": {
    "name": "protocol-policer-1",
    "namespace": "system",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "f4521ca8-3083-4f97-a4ad-c4e60fa838f8",
    "creation_timestamp": "2022-07-28T12:11:26.847615512Z",
    "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": {
    "protocol_policer": [
      {
        "protocol": {
          "tcp": {
            "flags": [
              "SYN"
            ]
          }
        },
        "policer": [
          {
            "kind": "policer",
            "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
            "tenant": "acmecorp",
            "namespace": "system",
            "name": "tcp-syn-limiter"
          }
        ]
      }
    ]
  }
}```
`

Request using curl:

    


curl -X 'POST' -d '{"metadata":{"name":"protocol-policer-1","namespace":"system"},"spec":{"protocol_policer":[{"protocol":{"tcp":{"flags":["SYN"]}},"policer":[{"kind":"policer","name":"tcp-syn-limiter"}]}]}}' -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/system/protocol_policers'



curl response:

	


HTTP/1.1 200 OK Content-Length: 1039 Content-Type: application/json Date: Thu, 28 Jul 2022 12:11:26 GMT Vary: Accept-Encoding

{ "metadata": { "name": "protocol-policer-1", "namespace": "system", "labels": { }, "annotations": { }, "description": "", "disable": false }, "system_metadata": { "uid": "f4521ca8-3083-4f97-a4ad-c4e60fa838f8", "creation_timestamp": "2022-07-28T12:11:26.847615512Z", "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": { "protocol_policer": [ { "protocol": { "tcp": { "flags": [ "SYN" ] } }, "policer": [ { "kind": "policer", "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff", "tenant": "acmecorp", "namespace": "system", "name": "tcp-syn-limiter" } ] } ] } }



Usecase:
--------
 Create protocol-policer-2 to rate limit all ICMP packets 

Request using vesctl:

    vesctl configuration create protocol_policer -i protocol_policer.yaml

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

	
RequestJSON:

```{"metadata":{"name":"protocol-policer-2","namespace":"system"},"spec":{"protocol_policer":[{"protocol":{"icmp":{"type":["ALL_ICMP_MSG"]}},"policer":[{"kind":"policer","name":"icmp-limiter"}]}]}}```
`

vesctl yaml response:

	
ResponseJSON:

```{
  "metadata": {
    "name": "protocol-policer-2",
    "namespace": "system",
    "labels": {
    },
    "annotations": {
    },
    "description": "",
    "disable": false
  },
  "system_metadata": {
    "uid": "17a450b4-f123-4e71-b167-36cce7f2a76e",
    "creation_timestamp": "2022-07-28T12:11:26.851020520Z",
    "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": {
    "protocol_policer": [
      {
        "protocol": {
          "icmp": {
            "type": [
              "ALL_ICMP_MSG"
            ]
          }
        },
        "policer": [
          {
            "kind": "policer",
            "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
            "tenant": "acmecorp",
            "namespace": "system",
            "name": "icmp-limiter"
          }
        ]
      }
    ]
  }
}```
`

Request using curl:

    


curl -X 'POST' -d '{"metadata":{"name":"protocol-policer-2","namespace":"system"},"spec":{"protocol_policer":[{"protocol":{"icmp":{"type":["ALL_ICMP_MSG"]}},"policer":[{"kind":"policer","name":"icmp-limiter"}]}]}}' -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/system/protocol_policers'



curl response:

	


HTTP/1.1 200 OK Content-Length: 1045 Content-Type: application/json Date: Thu, 28 Jul 2022 12:11:26 GMT Vary: Accept-Encoding

{ "metadata": { "name": "protocol-policer-2", "namespace": "system", "labels": { }, "annotations": { }, "description": "", "disable": false }, "system_metadata": { "uid": "17a450b4-f123-4e71-b167-36cce7f2a76e", "creation_timestamp": "2022-07-28T12:11:26.851020520Z", "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": { "protocol_policer": [ { "protocol": { "icmp": { "type": [ "ALL_ICMP_MSG" ] } }, "policer": [ { "kind": "policer", "uid": "ffffffff-ffff-ffff-ffff-ffffffffffff", "tenant": "acmecorp", "namespace": "system", "name": "icmp-limiter" } ] } ] } }