ves-io-schema-service_policy_rule-API-Replace

Examples of replacing service_policy_rule

Usecase:

Replace service-policy-rule-1

Request using vesctl:

vesctl configuration replace service_policy_rule -i service_policy_rule.yaml

where file service_policy_rule.yaml has following contents (service_policy_rule.ReplaceRequest):

RequestJSON:

{
    "metadata": {
        "name": "service-policy-rule-1",
        "namespace": "documentation"
    },
    "spec": {
        "action": "ALLOW",
        "client_name_matcher": {
            "regex_values": [
                ".+\.ves.io"
            ]
        },
        "client_role": {
            "match": "app-user"
        },
        "label_matcher": {
            "keys": [
                "ves.io/appType",
                "geoip.ves.io/region"
            ]
        },
        "path": {
            "exact_values": [
                "/register",
                "/guest-play"
            ]
        },
        "headers": [
            {
                "name": "Accept-Language",
                "item": {
                    "exact_values": [
                        "en-US"
                    ]
                }
            },
            {
                "name": "Accept-Encoding",
                "item": {
                    "exact_values": [
                        "gzip",
                        "deflate"
                    ]
                }
            }
        ],
        "any_ip": {},
        "any_asn": {},
        "waf_action": {
            "none": {}
        }
    }
}

vesctl yaml response: None

Request using curl:

curl -X 'PUT' -d '{"metadata":{"name":"service-policy-rule-1","namespace":"documentation"},"spec":{"action":"ALLOW","client_name_matcher":{"regex_values":[".+\.ves.io"]},"client_role":{"match":"app-user"},"label_matcher":{"keys":["ves.io/appType","geoip.ves.io/region"]},"path":{"exact_values":["/register","/guest-play"]},"headers":[{"name":"Accept-Language","item":{"exact_values":["en-US"]}},{"name":"Accept-Encoding","item":{"exact_values":["gzip","deflate"]}}],"any_ip":{},"any_asn":{},"waf_action":{"none":{}}}}' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build243329498_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/service_policy_rules/service-policy-rule-1'

curl response:

HTTP/1.1 200 OK
Content-Length: 4
Content-Type: application/json
Date: Fri, 23 Sep 2022 13:14:18 GMT
Vary: Accept-Encoding

{

}

Usecase:

Replace service-policy-rule-2

Request using vesctl:

vesctl configuration replace service_policy_rule -i service_policy_rule.yaml

where file service_policy_rule.yaml has following contents (service_policy_rule.ReplaceRequest):

RequestJSON:

{
    "metadata": {
        "name": "service-policy-rule-2",
        "namespace": "documentation"
    },
    "spec": {
        "action": "ALLOW",
        "client_selector": {
            "expressions": [
                "geoip.ves.io/region in (US-West, US-East), geoip.ves.io.city, geoip.ves.io.city notin (ves-io-sjc, ves-io-ny)"
            ]
        },
        "client_role": {
            "match": "app-user"
        },
        "label_matcher": {
            "keys": [
                "ves.io/appType",
                "geoip.ves.io/region"
            ]
        },
        "path": {
            "exact_values": [
                "/register",
                "/guest-play"
            ]
        },
        "headers": [
            {
                "name": "Accept-Language",
                "item": {
                    "exact_values": [
                        "en-US"
                    ]
                }
            },
            {
                "name": "Accept-Encoding",
                "item": {
                    "exact_values": [
                        "gzip",
                        "deflate"
                    ]
                }
            }
        ],
        "any_ip": {},
        "any_asn": {},
        "waf_action": {
            "none": {}
        }
    }
}

vesctl yaml response: None

Request using curl:

curl -X 'PUT' -d '{"metadata":{"name":"service-policy-rule-2","namespace":"documentation"},"spec":{"action":"ALLOW","client_selector":{"expressions":["geoip.ves.io/region in (US-West, US-East), geoip.ves.io.city, geoip.ves.io.city notin (ves-io-sjc, ves-io-ny)"]},"client_role":{"match":"app-user"},"label_matcher":{"keys":["ves.io/appType","geoip.ves.io/region"]},"path":{"exact_values":["/register","/guest-play"]},"headers":[{"name":"Accept-Language","item":{"exact_values":["en-US"]}},{"name":"Accept-Encoding","item":{"exact_values":["gzip","deflate"]}}],"any_ip":{},"any_asn":{},"waf_action":{"none":{}}}}' -H 'X-Volterra-Useragent: v1/pgm=_tmp_go-build243329498_b001_apidocs.test/host=docker-desktop' 'https://acmecorp.console.ves.volterra.io/api/config/namespaces/documentation/service_policy_rules/service-policy-rule-2'

curl response:

HTTP/1.1 200 OK
Content-Length: 4
Content-Type: application/json
Date: Fri, 23 Sep 2022 13:14:18 GMT
Vary: Accept-Encoding

{

}