class Google::Cloud::Trace::ResultSet

ResultSet represents the results of a `list_traces` request. It is an enumerable of the traces found, plus information about the request and a token to get the next page of results.

Attributes

end_time[R]

The `end_time` query parameter.

@return [Time, nil]

filter[R]

The `filter` query parameter.

@return [String, nil]

next_page_token[R]

The token to pass to `list_traces` to get the next page, or nil if this is the last page.

@return [String, nil]

order_by[R]

The `order_by` query parameter.

@return [String, nil]

page_size[R]

The `page_size` query parameter.

@return [Integer, nil]

page_token[R]

The page token used to obtain this page of results.

@return [String, nil]

project[R]

The project ID string.

@return [String]

service[R]

The trace service client that obtained this result set @private

start_time[R]

The `start_time` query parameter.

@return [Time, nil]

view[R]

The `view` query parameter.

@return [Symbol, nil]

Public Class Methods

from_gapic_page(service, project_id, page, start_time, end_time, filter: nil, order_by: nil, view: nil, page_size: nil, page_token: nil) click to toggle source

Create a new ResultSet given a Gapic::PagedEnumerable::Page, and all the query parameters.

@private

# File lib/google/cloud/trace/result_set.rb, line 177
def self.from_gapic_page service,
                         project_id,
                         page,
                         start_time,
                         end_time,
                         filter: nil,
                         order_by: nil,
                         view: nil,
                         page_size: nil,
                         page_token: nil
  next_page_token = page.next_page_token
  next_page_token = nil unless page.next_page_token?
  results = page.map do |proto|
    Google::Cloud::Trace::TraceRecord.from_grpc proto
  end
  new service,
      project_id,
      results,
      next_page_token,
      start_time,
      end_time,
      filter: filter,
      order_by: order_by,
      view: view,
      page_size: page_size,
      page_token: page_token
end
new(service, project, results, next_page_token, start_time, end_time, filter: nil, order_by: nil, view: nil, page_size: nil, page_token: nil) click to toggle source

Create a new ResultSet given an enumerable of result Trace objects, a next page token (or nil if this is the last page), and all the query parameters.

@private

# File lib/google/cloud/trace/result_set.rb, line 34
def initialize service, project,
               results, next_page_token,
               start_time, end_time,
               filter: nil,
               order_by: nil,
               view: nil,
               page_size: nil,
               page_token: nil
  @service = service
  @project = project
  @results = results
  @next_page_token = next_page_token
  @view = view
  @page_size = page_size
  @start_time = start_time
  @end_time = end_time
  @filter = filter
  @order_by = order_by
  @page_token = page_token
end

Public Instance Methods

each(&block) click to toggle source

An `each` method that supports the Enumerable module. Iterates over the results and yields each, as a {Google::Cloud::Trace::TraceRecord} object, to the given block. If no block is provided, returns an Enumerator.

# File lib/google/cloud/trace/result_set.rb, line 61
def each &block
  @results.each(&block)
end
next_page() click to toggle source

Queries the service for the next page of results and returns a new ResultSet for that page. Returns `nil` if there are no more results.

@return [Google::Cloud::Trace::ResultSet]

# File lib/google/cloud/trace/result_set.rb, line 158
def next_page
  return nil unless results_pending?
  service.list_traces \
    project,
    start_time,
    end_time,
    filter: filter,
    order_by: order_by,
    view: view,
    page_size: page_size,
    page_token: next_page_token
end
results_pending?() click to toggle source

Returns true if at least one more page of results can be retrieved.

@return [Boolean]

# File lib/google/cloud/trace/result_set.rb, line 148
def results_pending?
  !next_page_token.nil?
end
size() click to toggle source

Returns the number of traces in this page of results.

@return [Integer]

# File lib/google/cloud/trace/result_set.rb, line 70
def size
  @results.size
end