Class: Gapic::Presenters::SnippetPresenter::LroResponseHandlingPresenter

Inherits:
Object
  • Object
show all
Includes:
ResponseHandlingPresenterCommon
Defined in:
lib/gapic/presenters/snippet/response_handling_presenters.rb

Overview

Presentation information about LRO response handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, _json, phase1:) ⇒ LroResponseHandlingPresenter

Create an LRO response handling presenter

Parameters:

  • proto (Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1::Snippet::LroResponseHandling)

    The protobuf representation

  • json (String)

    The JSON representation

  • phase1 (Boolean)

    True if this is a phase 1 snippet without config



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 98

def initialize proto, _json, phase1:
  @response_name = compute_response_name proto, phase1
  @render_lines = []
  if @response_name
    if phase1
      @render_lines << "# The returned object is of type Gapic::Operation. You can use it to"
      @render_lines << "# check the status of an operation, cancel it, or wait for results."
    end
    case proto&.polling_type
    when :NONE
      # Do nothing
    when :ONCE
      @render_lines += check_once_lines phase1
    else
      @render_lines += wait_response_lines phase1
    end
  end
  @render = @render_lines.join "\n"
end

Instance Attribute Details

#renderString (readonly)

The rendered code as a single string, possibly with line breaks

Returns:

  • (String)


128
129
130
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 128

def render
  @render
end

#render_linesArray<String> (readonly)

The lines of rendered code

Returns:

  • (Array<String>)


122
123
124
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 122

def render_lines
  @render_lines
end

#response_nameString? (readonly)

The name of the response variable, or nil for no response handling

Returns:

  • (String, nil)


134
135
136
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 134

def response_name
  @response_name
end