Class: Gapic::Schema::Method

Inherits:
Proto
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gapic/schema/wrappers.rb

Overview

Wrapper for a protobuf method.

Constant Summary collapse

OPTION_EXTENSION_NAMES =
{
  "google.api.method_signature" => [1050, :string, :repeated],
  "google.api.http" => [72_295_728, ::Google::Api::HttpRule],
  "google.api.routing" => [72_295_729, ::Google::Api::RoutingRule],
  "google.cloud.operation_polling_method" => [1250, :bool],
  "google.cloud.operation_service" => [1249, :string],
  "google.longrunning.operation_info" => [1049, ::Google::Longrunning::OperationInfo]
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Proto

#address, #descriptor, #docs, #parent

Instance Method Summary collapse

Methods inherited from Proto

#containing_api, #containing_file, #docs_leading_comments, #leading_comments, #leading_detached_comments, #option_named, #path, #span, #trailing_comments

Constructor Details

#initialize(descriptor, address, docs, input, output) ⇒ Method

Initializes a method object.

Parameters:

  • descriptor (Google::Protobuf::MethodDescriptorProto)

    the protobuf representation of this service.

  • address (Enumerable<String>)

    The address of the proto. See

    address for more info.

  • docs (Google::Protobuf::SourceCodeInfo::Location)

    The docs of the proto. See #docs for more info.

  • input (Message)

    The input message of this method.

  • output (Message)

    The output message of this method.



383
384
385
386
387
# File 'lib/gapic/schema/wrappers.rb', line 383

def initialize descriptor, address, docs, input, output
  super descriptor, address, docs
  @input = input
  @output = output
end

Instance Attribute Details

#inputObject (readonly)

@ return [Message] The input message of this method.



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/gapic/schema/wrappers.rb', line 368

class Method < Proto
  extend Forwardable

  attr_reader :input
  attr_reader :output

  # Initializes a method object.
  # @param descriptor [Google::Protobuf::MethodDescriptorProto] the
  #   protobuf representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param input [Message] The input message of this method.
  # @param output [Message] The output message of this method.
  def initialize descriptor, address, docs, input, output
    super descriptor, address, docs
    @input = input
    @output = output
  end

  OPTION_EXTENSION_NAMES = {
    "google.api.method_signature" => [1050, :string, :repeated],
    "google.api.http" => [72_295_728, ::Google::Api::HttpRule],
    "google.api.routing" => [72_295_729, ::Google::Api::RoutingRule],
    "google.cloud.operation_polling_method" => [1250, :bool],
    "google.cloud.operation_service" => [1249, :string],
    "google.longrunning.operation_info" => [1049, ::Google::Longrunning::OperationInfo]
  }.freeze

  ##
  # Return a configuration of supported option extensions.
  #
  def option_extension_names
    OPTION_EXTENSION_NAMES
  end

  # @return [Array<Array<String>>] The parameter lists
  #   defined for this method. See `google/api/client.proto`.
  def signatures
    return [] if options.nil?

    Array(option_named("google.api.method_signature")).map do |sig|
      String(sig).split ","
    end
  end

  # @return [Google::Longrunning::OperationInfo] Additional information
  #   regarding long-running operations.
  #   In particular, this specifies the types that are returned from
  #   long-running operations.
  #   Required for methods that return `google.longrunning.Operation`;
  #   invalid otherwise.
  def operation_info
    option_named "google.longrunning.operation_info"
  end

  # @return [Boolean] True if this method is marked as deprecated, false
  #   otherwise.
  def is_deprecated?
    option_named("deprecated") == true
  end

  # @return [Google::Api::HttpRule] The HTTP bindings for this method. See
  #   `google/api/http.proto`.
  def http
    option_named "google.api.http"
  end

  # @return [Google::Api::RoutingRule] The Routing bindings for this method. See
  #   `google/api/routing.proto`.
  def routing
    option_named "google.api.routing"
  end

  # @return [String] The full name for this method
  #   (e.g. `google.example.Service.Rpc`).
  #   Useful when matching against other pieces of information
  #   which also reference full proto name.
  def full_name
    @address.join "."
  end

  # Nonstandard LRO annotation.
  # @return [String] Name of the nonstandard LRO service
  #   that should be used for polling the operation object
  #   that this method returns
  def operation_service
    option_named "google.cloud.operation_service"
  end

  # Nonstandard LRO annotation.
  # @return [Boolean] Whether this method is a polling method
  #   for a nonstandard LRO service
  def polling_method
    option_named "google.cloud.operation_polling_method"
  end

  # @!method name
  #   @return [String] the unqualified name of the method.
  # @!method options
  #   @return [Google::Protobuf::MethodOptions] the options of this
  #     method.
  # @!method client_streaming
  #   @return [Boolean]
  #     Identifies if client streams multiple client messages.
  # @!method server_streaming
  #   @return [Boolean]
  #     Identifies if server streams multiple server messages.
  def_delegators(
    :descriptor,
    :name,
    :options,
    :client_streaming,
    :server_streaming
  )
end

#outputObject (readonly)

@ return [Message] The output message of this method.



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/gapic/schema/wrappers.rb', line 368

class Method < Proto
  extend Forwardable

  attr_reader :input
  attr_reader :output

  # Initializes a method object.
  # @param descriptor [Google::Protobuf::MethodDescriptorProto] the
  #   protobuf representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param input [Message] The input message of this method.
  # @param output [Message] The output message of this method.
  def initialize descriptor, address, docs, input, output
    super descriptor, address, docs
    @input = input
    @output = output
  end

  OPTION_EXTENSION_NAMES = {
    "google.api.method_signature" => [1050, :string, :repeated],
    "google.api.http" => [72_295_728, ::Google::Api::HttpRule],
    "google.api.routing" => [72_295_729, ::Google::Api::RoutingRule],
    "google.cloud.operation_polling_method" => [1250, :bool],
    "google.cloud.operation_service" => [1249, :string],
    "google.longrunning.operation_info" => [1049, ::Google::Longrunning::OperationInfo]
  }.freeze

  ##
  # Return a configuration of supported option extensions.
  #
  def option_extension_names
    OPTION_EXTENSION_NAMES
  end

  # @return [Array<Array<String>>] The parameter lists
  #   defined for this method. See `google/api/client.proto`.
  def signatures
    return [] if options.nil?

    Array(option_named("google.api.method_signature")).map do |sig|
      String(sig).split ","
    end
  end

  # @return [Google::Longrunning::OperationInfo] Additional information
  #   regarding long-running operations.
  #   In particular, this specifies the types that are returned from
  #   long-running operations.
  #   Required for methods that return `google.longrunning.Operation`;
  #   invalid otherwise.
  def operation_info
    option_named "google.longrunning.operation_info"
  end

  # @return [Boolean] True if this method is marked as deprecated, false
  #   otherwise.
  def is_deprecated?
    option_named("deprecated") == true
  end

  # @return [Google::Api::HttpRule] The HTTP bindings for this method. See
  #   `google/api/http.proto`.
  def http
    option_named "google.api.http"
  end

  # @return [Google::Api::RoutingRule] The Routing bindings for this method. See
  #   `google/api/routing.proto`.
  def routing
    option_named "google.api.routing"
  end

  # @return [String] The full name for this method
  #   (e.g. `google.example.Service.Rpc`).
  #   Useful when matching against other pieces of information
  #   which also reference full proto name.
  def full_name
    @address.join "."
  end

  # Nonstandard LRO annotation.
  # @return [String] Name of the nonstandard LRO service
  #   that should be used for polling the operation object
  #   that this method returns
  def operation_service
    option_named "google.cloud.operation_service"
  end

  # Nonstandard LRO annotation.
  # @return [Boolean] Whether this method is a polling method
  #   for a nonstandard LRO service
  def polling_method
    option_named "google.cloud.operation_polling_method"
  end

  # @!method name
  #   @return [String] the unqualified name of the method.
  # @!method options
  #   @return [Google::Protobuf::MethodOptions] the options of this
  #     method.
  # @!method client_streaming
  #   @return [Boolean]
  #     Identifies if client streams multiple client messages.
  # @!method server_streaming
  #   @return [Boolean]
  #     Identifies if server streams multiple server messages.
  def_delegators(
    :descriptor,
    :name,
    :options,
    :client_streaming,
    :server_streaming
  )
end

Instance Method Details

#client_streamingBoolean

Returns Identifies if client streams multiple client messages.

Returns:

  • (Boolean)

    Identifies if client streams multiple client messages.



477
478
479
480
481
482
483
# File 'lib/gapic/schema/wrappers.rb', line 477

def_delegators(
  :descriptor,
  :name,
  :options,
  :client_streaming,
  :server_streaming
)

#full_nameString

Returns The full name for this method (e.g. google.example.Service.Rpc). Useful when matching against other pieces of information which also reference full proto name.

Returns:

  • (String)

    The full name for this method (e.g. google.example.Service.Rpc). Useful when matching against other pieces of information which also reference full proto name.



447
448
449
# File 'lib/gapic/schema/wrappers.rb', line 447

def full_name
  @address.join "."
end

#httpGoogle::Api::HttpRule

Returns The HTTP bindings for this method. See google/api/http.proto.

Returns:

  • (Google::Api::HttpRule)

    The HTTP bindings for this method. See google/api/http.proto.



433
434
435
# File 'lib/gapic/schema/wrappers.rb', line 433

def http
  option_named "google.api.http"
end

#is_deprecated?Boolean

Returns True if this method is marked as deprecated, false otherwise.

Returns:

  • (Boolean)

    True if this method is marked as deprecated, false otherwise.



427
428
429
# File 'lib/gapic/schema/wrappers.rb', line 427

def is_deprecated?
  option_named("deprecated") == true
end

#nameString

Returns the unqualified name of the method.

Returns:

  • (String)

    the unqualified name of the method.



477
478
479
480
481
482
483
# File 'lib/gapic/schema/wrappers.rb', line 477

def_delegators(
  :descriptor,
  :name,
  :options,
  :client_streaming,
  :server_streaming
)

#operation_infoGoogle::Longrunning::OperationInfo

Returns Additional information regarding long-running operations. In particular, this specifies the types that are returned from long-running operations. Required for methods that return google.longrunning.Operation; invalid otherwise.

Returns:

  • (Google::Longrunning::OperationInfo)

    Additional information regarding long-running operations. In particular, this specifies the types that are returned from long-running operations. Required for methods that return google.longrunning.Operation; invalid otherwise.



421
422
423
# File 'lib/gapic/schema/wrappers.rb', line 421

def operation_info
  option_named "google.longrunning.operation_info"
end

#operation_serviceString

Nonstandard LRO annotation.

Returns:

  • (String)

    Name of the nonstandard LRO service that should be used for polling the operation object that this method returns



455
456
457
# File 'lib/gapic/schema/wrappers.rb', line 455

def operation_service
  option_named "google.cloud.operation_service"
end

#option_extension_namesObject

Return a configuration of supported option extensions.



401
402
403
# File 'lib/gapic/schema/wrappers.rb', line 401

def option_extension_names
  OPTION_EXTENSION_NAMES
end

#optionsGoogle::Protobuf::MethodOptions

Returns the options of this method.

Returns:

  • (Google::Protobuf::MethodOptions)

    the options of this method.



477
478
479
480
481
482
483
# File 'lib/gapic/schema/wrappers.rb', line 477

def_delegators(
  :descriptor,
  :name,
  :options,
  :client_streaming,
  :server_streaming
)

#polling_methodBoolean

Nonstandard LRO annotation.

Returns:

  • (Boolean)

    Whether this method is a polling method for a nonstandard LRO service



462
463
464
# File 'lib/gapic/schema/wrappers.rb', line 462

def polling_method
  option_named "google.cloud.operation_polling_method"
end

#routingGoogle::Api::RoutingRule

Returns The Routing bindings for this method. See google/api/routing.proto.

Returns:

  • (Google::Api::RoutingRule)

    The Routing bindings for this method. See google/api/routing.proto.



439
440
441
# File 'lib/gapic/schema/wrappers.rb', line 439

def routing
  option_named "google.api.routing"
end

#server_streamingBoolean

Returns Identifies if server streams multiple server messages.

Returns:

  • (Boolean)

    Identifies if server streams multiple server messages.



477
478
479
480
481
482
483
# File 'lib/gapic/schema/wrappers.rb', line 477

def_delegators(
  :descriptor,
  :name,
  :options,
  :client_streaming,
  :server_streaming
)

#signaturesArray<Array<String>>

Returns The parameter lists defined for this method. See google/api/client.proto.

Returns:

  • (Array<Array<String>>)

    The parameter lists defined for this method. See google/api/client.proto.



407
408
409
410
411
412
413
# File 'lib/gapic/schema/wrappers.rb', line 407

def signatures
  return [] if options.nil?

  Array(option_named("google.api.method_signature")).map do |sig|
    String(sig).split ","
  end
end