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=_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/service_policy_rules/service-policy-rule-1'
        

curl response:

          HTTP/1.1 200 OK
Content-Length: 4
Content-Type: application/json
Date: Thu, 21 Mar 2024 14:07:03 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=_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/service_policy_rules/service-policy-rule-2'
        

curl response:

          HTTP/1.1 200 OK
Content-Length: 4
Content-Type: application/json
Date: Thu, 21 Mar 2024 14:07:03 GMT
Vary: Accept-Encoding

{

}