def create_api_call(func, settings):
    """Converts an rpc call into an API call governed by the settings.

    In typical usage, ``func`` will be a callable used to make an rpc request.
    This will mostly likely be a bound method from a request stub used to make
    an rpc call.

    The result is created by applying a series of function decorators defined
    in this module to ``func``.  ``settings`` is used to determine which
    function decorators to apply.

    The result is another callable which for most values of ``settings`` has
    has the same signature as the original. Only when ``settings`` configures
    bundling does the signature change.

    Args:
      func (Callable[Sequence[object], object]): is used to make a bare rpc
        call.
      settings (_CallSettings): provides the settings for this call

    Returns:
      Callable[Sequence[object], object]: a bound method on a request stub used
        to make an rpc call

    Raises:
       ValueError: if ``settings`` has incompatible values, e.g, if bundling
         and page_streaming are both configured

    """
    def base_caller(api_call, _, *args):
        """Simply call api_call and ignore settings."""
        return api_call(*args)

    def inner(request, options=None):
        """Invoke with the actual settings."""
        this_options = _merge_options_metadata(options, settings)
        this_settings = settings.merge(this_options)

        if this_settings.retry and this_settings.retry.retry_codes:
            api_call = gax.retry.retryable(
                func, this_settings.retry, **this_settings.kwargs)
        else:
            api_call = gax.retry.add_timeout_arg(
                func, this_settings.timeout, **this_settings.kwargs)
        api_call = _catch_errors(api_call, gax.config.API_ERRORS)
        return api_caller(api_call, this_settings, request)

    if settings.page_descriptor:
        if settings.bundler and settings.bundle_descriptor:
            raise ValueError('The API call has incompatible settings: '
                             'bundling and page streaming')
        api_caller = _page_streamable(settings.page_descriptor)
    elif settings.bundler and settings.bundle_descriptor:
        api_caller = _bundleable(settings.bundle_descriptor)
    else:
        api_caller = base_caller

    return inner
def create_api_call ( func , settings ) : def base_caller ( api_call , _ , * args ) : return api_call ( * args ) def inner ( request , options = None ) : this_options = _merge_options_metadata ( options , settings ) this_settings = settings . merge ( this_options ) if this_settings . retry and this_settings . retry . retry_codes : api_call = gax . retry . retryable ( func , this_settings . retry , ** this_settings . kwargs ) else : api_call = gax . retry . add_timeout_arg ( func , this_settings . timeout , ** this_settings . kwargs ) api_call = _catch_errors ( api_call , gax . config . API_ERRORS ) return api_caller ( api_call , this_settings , request ) if settings . page_descriptor : if settings . bundler and settings . bundle_descriptor : raise ValueError ( 'The API call has incompatible settings: ' 'bundling and page streaming' ) api_caller = _page_streamable ( settings . page_descriptor ) elif settings . bundler and settings . bundle_descriptor : api_caller = _bundleable ( settings . bundle_descriptor ) else : api_caller = base_caller return inner
Converts an rpc call into an API call governed by the settings.

    In typical usage, ``func`` will be a callable used to make an rpc request.
    This will mostly likely be a bound method from a request stub used to make
    an rpc call.

    The result is created by applying a series of function decorators defined
    in this module to ``func``.  ``settings`` is used to determine which
    function decorators to apply.

    The result is another callable which for most values of ``settings`` has
    has the same signature as the original. Only when ``settings`` configures
    bundling does the signature change.

    Args:
      func (Callable[Sequence[object], object]): is used to make a bare rpc
        call.
      settings (_CallSettings): provides the settings for this call

    Returns:
      Callable[Sequence[object], object]: a bound method on a request stub used
        to make an rpc call

    Raises:
       ValueError: if ``settings`` has incompatible values, e.g, if bundling
         and page_streaming are both configured