Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% extends '_base.py.j2' %}

{% block content %}
{% set has_auto_populated_fields = api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}

{% import "%namespace/%name/%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}

from collections import OrderedDict
import os
import re
from typing import Callable, Dict, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}Iterable, {% endif %}{% if service.any_client_streaming %}Iterator, {% endif %}Sequence, Tuple, Type, Union, cast
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
import uuid
{% endif %}
{% if service.any_deprecated %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{% extends "_base.py.j2" %}

{% block content %}
{% set has_auto_populated_fields = api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}


{% import "%namespace/%name/%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}

import os
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
import re
{% endif %}
from unittest import mock
Expand Down Expand Up @@ -70,7 +72,7 @@ from google.iam.v1 import policy_pb2 # type: ignore
{% endfilter %}
{{ shared_macros.add_google_api_core_version_header_import(service.version) }}

{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|list %}
{% if has_auto_populated_fields %}
_UUID4_RE = re.compile(r"{{ uuid4_re }}")
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% extends "_base.py.j2" %}

{% block content %}
{% set has_auto_populated_fields = api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% import "%namespace/%name_%version/%sub/services/%service/_client_macros.j2" as macros %}
{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}

import logging as std_logging
from collections import OrderedDict
import re
from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}AsyncIterable, Awaitable, {% endif %}{% if service.any_client_streaming %}AsyncIterator, {% endif %}Sequence, Tuple, Type, Union
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
import uuid
{% endif %}
{% if service.any_deprecated %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% extends '_base.py.j2' %}

{% block content %}
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% set has_auto_populated_fields = api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% import "%namespace/%name_%version/%sub/services/%service/_client_macros.j2" as macros %}
{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}

Expand All @@ -16,7 +16,7 @@ import logging as std_logging
import os
import re
from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}Iterable, {% endif %}{% if service.any_client_streaming %}Iterator, {% endif %}Sequence, Tuple, Type, Union, cast
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
import uuid
{% endif %}
import warnings
Expand Down Expand Up @@ -453,7 +453,8 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
# NOTE (b/349488459): universe validation is disabled until further notice.
return True

{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}

@staticmethod
def _setup_request_id(request, field_name: str, is_proto3_optional: bool):
"""Populate a UUID4 field in the request if it is not already set.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% extends "_base.py.j2" %}

{% block content %}
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% set has_auto_populated_fields = api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% import "tests/unit/gapic/%name_%version/%sub/test_macros.j2" as test_macros %}
{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}

import os
import asyncio
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
import re
{% endif %}
from unittest import mock
Expand Down Expand Up @@ -107,7 +107,7 @@ CRED_INFO_JSON = {
"principal": "service-account@example.com",
}
CRED_INFO_STRING = json.dumps(CRED_INFO_JSON)
{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
_UUID4_RE = re.compile(r"{{ uuid4_re }}")
{% endif %}

Expand Down Expand Up @@ -434,7 +434,7 @@ def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code):
client._add_cred_info_for_auth_errors(error)
assert error.details == []

{% if api.all_method_settings.values()|map(attribute="auto_populated_fields", default=[])|select|list %}
{% if has_auto_populated_fields %}
def test__setup_request_id():
class MockRequest:
def __init__(self, **kwargs):
Expand Down
Loading