Class: Gapic::Presenters::Method::RestPaginationInfo

Inherits:
Object
  • Object
show all
Includes:
Helpers::NamespaceHelper
Defined in:
lib/gapic/presenters/method/rest_pagination_info.rb

Overview

Pagination info determined from the proto method

Instance Method Summary collapse

Methods included from Helpers::NamespaceHelper

#ensure_absolute_namespace, #fix_namespace, #ruby_namespace, #ruby_namespace_for_address

Constructor Details

#initialize(proto_method, api) ⇒ RestPaginationInfo

Returns a new instance of RestPaginationInfo.

Parameters:



29
30
31
32
33
34
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 29

def initialize proto_method, api
  @api = api
  @request = proto_method.input
  @response = proto_method.output
  @server_streaming = proto_method.server_streaming
end

Instance Method Details

#paged?Boolean

Whether the method should be generated as paged

Returns:

  • (Boolean)


40
41
42
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 40

def paged?
  !server_streaming? && paged_request? && paged_response?
end

#paged_element_doc_typeString?

Proto type of the repeated field in the response message

Returns:

  • (String, nil)


74
75
76
77
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 74

def paged_element_doc_type
  return nil if response_results_field.nil?
  field_paginated_elem_doc_type response_results_field
end

#repeated_field_is_a_map?Boolean?

Whether the repeated field in the response message is a map

Returns:

  • (Boolean, nil)


66
67
68
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 66

def repeated_field_is_a_map?
  response_results_field&.map?
end

#request_page_size_nameString?

Name of the request's field used for page size For Regapic can be either page_size or max_results

Returns:

  • (String, nil)


49
50
51
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 49

def request_page_size_name
  request_page_size_field&.name
end

#response_repeated_field_nameString?

Name of the repeated field in the response message For REST gapics can be either a vanilla repeated field or a map

Returns:

  • (String, nil)


58
59
60
# File 'lib/gapic/presenters/method/rest_pagination_info.rb', line 58

def response_repeated_field_name
  response_results_field&.name
end