Returns of a list of traces that match the specified filter conditions.

        Example:
            >>> from google.cloud import trace_v1
            >>>
            >>> client = trace_v1.TraceServiceClient()
            >>>
            >>> # TODO: Initialize `project_id`:
            >>> project_id = ''
            >>>
            >>> # Iterate over all results
            >>> for element in client.list_traces(project_id):
            ...     # process element
            ...     pass
            >>>
            >>>
            >>> # Alternatively:
            >>>
            >>> # Iterate over results one page at a time
            >>> for page in client.list_traces(project_id).pages:
            ...     for element in page:
            ...         # process element
            ...         pass

        Args:
            project_id (str): ID of the Cloud project where the trace data is stored.
            view (~google.cloud.trace_v1.types.ViewType): Type of data returned for traces in the list. Optional. Default is
                ``MINIMAL``.
            page_size (int): The maximum number of resources contained in the
                underlying API response. If page streaming is performed per-
                resource, this parameter does not affect the return value. If page
                streaming is performed per-page, this determines the maximum number
                of resources in a page.
            start_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): Start of the time interval (inclusive) during which the trace data was
                collected from the application.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v1.types.Timestamp`
            end_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): End of the time interval (inclusive) during which the trace data was
                collected from the application.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v1.types.Timestamp`
            filter_ (str): An optional filter against labels for the request.

                By default, searches use prefix matching. To specify exact match,
                prepend a plus symbol (``+``) to the search term. Multiple terms are
                ANDed. Syntax:

                -  ``root:NAME_PREFIX`` or ``NAME_PREFIX``: Return traces where any root
                   span starts with ``NAME_PREFIX``.
                -  ``+root:NAME`` or ``+NAME``: Return traces where any root span's name
                   is exactly ``NAME``.
                -  ``span:NAME_PREFIX``: Return traces where any span starts with
                   ``NAME_PREFIX``.
                -  ``+span:NAME``: Return traces where any span's name is exactly
                   ``NAME``.
                -  ``latency:DURATION``: Return traces whose overall latency is greater
                   or equal to than ``DURATION``. Accepted units are nanoseconds
                   (``ns``), milliseconds (``ms``), and seconds (``s``). Default is
                   ``ms``. For example, ``latency:24ms`` returns traces whose overall
                   latency is greater than or equal to 24 milliseconds.
                -  ``label:LABEL_KEY``: Return all traces containing the specified label
                   key (exact match, case-sensitive) regardless of the key:value pair's
                   value (including empty values).
                -  ``LABEL_KEY:VALUE_PREFIX``: Return all traces containing the
                   specified label key (exact match, case-sensitive) whose value starts
                   with ``VALUE_PREFIX``. Both a key and a value must be specified.
                -  ``+LABEL_KEY:VALUE``: Return all traces containing a key:value pair
                   exactly matching the specified text. Both a key and a value must be
                   specified.
                -  ``method:VALUE``: Equivalent to ``/http/method:VALUE``.
                -  ``url:VALUE``: Equivalent to ``/http/url:VALUE``.
            order_by (str): Field used to sort the returned traces. Optional. Can be one of the
                following:

                -  ``trace_id``
                -  ``name`` (``name`` field of root span in the trace)
                -  ``duration`` (difference between ``end_time`` and ``start_time``
                   fields of the root span)
                -  ``start`` (``start_time`` field of the root span)

                Descending order can be specified by appending ``desc`` to the sort
                field (for example, ``name desc``).

                Only one sort field is permitted.
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.gax.PageIterator` instance. By default, this
            is an iterable of :class:`~google.cloud.trace_v1.types.Trace` instances.
            This object can also be configured to iterate over the pages
            of the response through the `options` parameter.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.

def list_traces(
        self,
        project_id,
        view=None,
        page_size=None,
        start_time=None,
        end_time=None,
        filter_=None,
        order_by=None,
        retry=google.api_core.gapic_v1.method.DEFAULT,
        timeout=google.api_core.gapic_v1.method.DEFAULT,
        metadata=None,
    ):
        """
        Returns of a list of traces that match the specified filter conditions.

        Example:
            >>> from google.cloud import trace_v1
            >>>
            >>> client = trace_v1.TraceServiceClient()
            >>>
            >>> # TODO: Initialize `project_id`:
            >>> project_id = ''
            >>>
            >>> # Iterate over all results
            >>> for element in client.list_traces(project_id):
            ...     # process element
            ...     pass
            >>>
            >>>
            >>> # Alternatively:
            >>>
            >>> # Iterate over results one page at a time
            >>> for page in client.list_traces(project_id).pages:
            ...     for element in page:
            ...         # process element
            ...         pass

        Args:
            project_id (str): ID of the Cloud project where the trace data is stored.
            view (~google.cloud.trace_v1.types.ViewType): Type of data returned for traces in the list. Optional. Default is
                ``MINIMAL``.
            page_size (int): The maximum number of resources contained in the
                underlying API response. If page streaming is performed per-
                resource, this parameter does not affect the return value. If page
                streaming is performed per-page, this determines the maximum number
                of resources in a page.
            start_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): Start of the time interval (inclusive) during which the trace data was
                collected from the application.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v1.types.Timestamp`
            end_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): End of the time interval (inclusive) during which the trace data was
                collected from the application.

                If a dict is provided, it must be of the same form as the protobuf
                message :class:`~google.cloud.trace_v1.types.Timestamp`
            filter_ (str): An optional filter against labels for the request.

                By default, searches use prefix matching. To specify exact match,
                prepend a plus symbol (``+``) to the search term. Multiple terms are
                ANDed. Syntax:

                -  ``root:NAME_PREFIX`` or ``NAME_PREFIX``: Return traces where any root
                   span starts with ``NAME_PREFIX``.
                -  ``+root:NAME`` or ``+NAME``: Return traces where any root span's name
                   is exactly ``NAME``.
                -  ``span:NAME_PREFIX``: Return traces where any span starts with
                   ``NAME_PREFIX``.
                -  ``+span:NAME``: Return traces where any span's name is exactly
                   ``NAME``.
                -  ``latency:DURATION``: Return traces whose overall latency is greater
                   or equal to than ``DURATION``. Accepted units are nanoseconds
                   (``ns``), milliseconds (``ms``), and seconds (``s``). Default is
                   ``ms``. For example, ``latency:24ms`` returns traces whose overall
                   latency is greater than or equal to 24 milliseconds.
                -  ``label:LABEL_KEY``: Return all traces containing the specified label
                   key (exact match, case-sensitive) regardless of the key:value pair's
                   value (including empty values).
                -  ``LABEL_KEY:VALUE_PREFIX``: Return all traces containing the
                   specified label key (exact match, case-sensitive) whose value starts
                   with ``VALUE_PREFIX``. Both a key and a value must be specified.
                -  ``+LABEL_KEY:VALUE``: Return all traces containing a key:value pair
                   exactly matching the specified text. Both a key and a value must be
                   specified.
                -  ``method:VALUE``: Equivalent to ``/http/method:VALUE``.
                -  ``url:VALUE``: Equivalent to ``/http/url:VALUE``.
            order_by (str): Field used to sort the returned traces. Optional. Can be one of the
                following:

                -  ``trace_id``
                -  ``name`` (``name`` field of root span in the trace)
                -  ``duration`` (difference between ``end_time`` and ``start_time``
                   fields of the root span)
                -  ``start`` (``start_time`` field of the root span)

                Descending order can be specified by appending ``desc`` to the sort
                field (for example, ``name desc``).

                Only one sort field is permitted.
            retry (Optional[google.api_core.retry.Retry]):  A retry object used
                to retry requests. If ``None`` is specified, requests will not
                be retried.
            timeout (Optional[float]): The amount of time, in seconds, to wait
                for the request to complete. Note that if ``retry`` is
                specified, the timeout applies to each individual attempt.
            metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
                that is provided to the method.

        Returns:
            A :class:`~google.gax.PageIterator` instance. By default, this
            is an iterable of :class:`~google.cloud.trace_v1.types.Trace` instances.
            This object can also be configured to iterate over the pages
            of the response through the `options` parameter.

        Raises:
            google.api_core.exceptions.GoogleAPICallError: If the request
                    failed for any reason.
            google.api_core.exceptions.RetryError: If the request failed due
                    to a retryable error and retry attempts failed.
            ValueError: If the parameters are invalid.
        """
        # Wrap the transport method to add retry and timeout logic.
        if "list_traces" not in self._inner_api_calls:
            self._inner_api_calls[
                "list_traces"
            ] = google.api_core.gapic_v1.method.wrap_method(
                self.transport.list_traces,
                default_retry=self._method_configs["ListTraces"].retry,
                default_timeout=self._method_configs["ListTraces"].timeout,
                client_info=self._client_info,
            )

        request = trace_pb2.ListTracesRequest(
            project_id=project_id,
            view=view,
            page_size=page_size,
            start_time=start_time,
            end_time=end_time,
            filter=filter_,
            order_by=order_by,
        )
        if metadata is None:
            metadata = []
        metadata = list(metadata)
        try:
            routing_header = [("project_id", project_id)]
        except AttributeError:
            pass
        else:
            routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
                routing_header
            )
            metadata.append(routing_metadata)

        iterator = google.api_core.page_iterator.GRPCIterator(
            client=None,
            method=functools.partial(
                self._inner_api_calls["list_traces"],
                retry=retry,
                timeout=timeout,
                metadata=metadata,
            ),
            request=request,
            items_field="traces",
            request_token_field="page_token",
            response_token_field="next_page_token",
        )
        return iterator