1# Copyright 2020 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""AsyncIO helpers for loading gapic configuration data.
15
16The Google API generator creates supplementary configuration for each RPC
17method to tell the client library how to deal with retries and timeouts.
18"""
19
20from google.api_core import retry_async
21from google.api_core.gapic_v1 import config
22from google.api_core.gapic_v1.config import MethodConfig # noqa: F401
23
24
25def parse_method_configs(interface_config):
26 """Creates default retry and timeout objects for each method in a gapic
27 interface config with AsyncIO semantics.
28
29 Args:
30 interface_config (Mapping): The interface config section of the full
31 gapic library config. For example, If the full configuration has
32 an interface named ``google.example.v1.ExampleService`` you would
33 pass in just that interface's configuration, for example
34 ``gapic_config['interfaces']['google.example.v1.ExampleService']``.
35
36 Returns:
37 Mapping[str, MethodConfig]: A mapping of RPC method names to their
38 configuration.
39 """
40 return config.parse_method_configs(
41 interface_config, retry_impl=retry_async.AsyncRetry
42 )