File: api_version_policy.py

package info (click to toggle)
python-azure 20251104%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 770,224 kB
  • sloc: python: 6,357,217; ansic: 804; javascript: 287; makefile: 198; sh: 193; xml: 109
file content (13 lines) | stat: -rw-r--r-- 375 bytes parent folder | download | duplicates (4)
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