File: client.py.jinja2

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (42 lines) | stat: -rw-r--r-- 1,543 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{% set def = "async def" if async_mode else "def" %}
{% set a_prefix = "a" if async_mode else "" %}
{% set await = "await " if async_mode else "" %}
{% set generated_client = code_model.client.generated_class(async_mode) %}
{{ imports }}
from .operations import (
    {% for operation_group in code_model.operation_groups %}
    {{ operation_group.name }},
    {% endfor %}
)
from {{ ".." if async_mode else "." }}_validation import api_version_validation
from {{ ".." if async_mode else "." }} import models
{{ client_initialization }}

    @classmethod
    def _models_dict(cls):
        return {k: v for k, v in models.__dict__.items() if isinstance(v, type)}

{% for operation_group in operation_group_properties %}

    @property
    {% if operation_group.need_decorator %}
    {{ operation_group.decorator | indent }}
    {% endif %}
    def {{ operation_group.property_name }}(self):
        api_version = self._get_api_version("{{ operation_group.property_name }}")
        return {{ operation_group.name }}(
            self._client,
            self._config,
            Serializer(self._models_dict()),
            Deserializer(self._models_dict()),
            api_version=api_version,
        )
    {% endfor %}

    {{ def }} close(self):
        {{ await }}self._client.close()
    {{ def }} __{{ a_prefix }}enter__(self):
        {{ await }}self._client.__{{ a_prefix }}enter__()
        return self
    {{ def }} __{{ a_prefix }}exit__(self, *exc_details):
        {{ await }}self._client.__{{ a_prefix }}exit__(*exc_details)