File: api_version_policy.py

package info (click to toggle)
python-azure 20251202%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 786,344 kB
  • sloc: python: 6,510,493; ansic: 804; javascript: 287; sh: 204; makefile: 198; xml: 109
file content (13 lines) | stat: -rw-r--r-- 375 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
from azure.core.pipeline.policies import SansIOHTTPPolicy


class ApiVersionAssertPolicy(SansIOHTTPPolicy):
    """
    Assert the ApiVersion is set properly on the response
    """

    def __init__(self, api_version):
        self.api_version = api_version

    def on_request(self, request):
        assert request.http_request.headers["x-ms-version"] == self.api_version