File: client.py.jinja2

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (41 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download
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
{% 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
{{ client_initialization }}

{{ getsource(generated_client._models_dict) }}

{{ getsource(generated_client.models) }}

{% 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(api_version)),
            Deserializer(self._models_dict(api_version)),
            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)