Class: Gapic::Schema::Field
- Extended by:
- Forwardable
- Defined in:
- lib/gapic/schema/wrappers.rb
Overview
Wrapper for a protobuf Field.
Instance Attribute Summary collapse
-
#enum ⇒ Object
@ return [Enum | nil] The enum if the field is an enum, nil otherwise.
-
#message ⇒ Object
@ return [Message | nil] The message if the field is a message, nil otherwise.
Attributes inherited from Proto
#address, #descriptor, #docs, #parent
Instance Method Summary collapse
-
#default_value ⇒ String
For numeric types, contains the original text representation of the value.
-
#enum? ⇒ Boolean
Whether this field is an enum.
-
#field_behavior ⇒ Array<Google::Api::FieldBehavior>
A designation of a specific field behavior (required, output only, etc.) in protobuf messages.
-
#full_name ⇒ String
The full name for this field (e.g.
google.example.Message.field). -
#immutable? ⇒ Boolean
Denotes a field as immutable.
-
#initialize(descriptor, address, docs, message, enum) ⇒ Field
constructor
Initializes a message object.
-
#input_only? ⇒ Boolean
Denotes a field as input only.
-
#json_name ⇒ String
JSON name of this field.
-
#label ⇒ Google::Protobuf::FieldDescriptorProto::Label
The label of the field.
-
#map? ⇒ Boolean
Whether this field is a map.
-
#map_key_field ⇒ Field?
A key field for this map or nil if this field is not a map.
-
#map_val_field ⇒ Field?
A value field for this map or nil if this field is not a map.
-
#message? ⇒ Boolean
Whether this field is a message.
-
#name ⇒ String
The unqualified name of the field.
-
#number ⇒ Integer
The number of the field.
-
#oneof? ⇒ Boolean
Denotes a field as a part of oneof.
-
#oneof_index ⇒ Integer
If set, gives the index of a oneof in the containing type's oneof_decl list.
-
#operation_field ⇒ Integer
Nonstandard LRO annotation.
-
#operation_request_field ⇒ String
Nonstandard LRO annotation.
-
#operation_response_field ⇒ String
Nonstandard LRO annotation.
-
#optional? ⇒ Boolean
Specifically denotes a field as optional.
-
#options ⇒ Google::Protobuf::FieldOptions
The options of this field.
-
#output_only? ⇒ Boolean
Denotes a field as output only.
-
#repeated? ⇒ Boolean
Whether this field is a repeated field.
-
#required? ⇒ Boolean
Denotes a field as required.
-
#resource_reference ⇒ String
A reference to another resource message or resource definition.
-
#type ⇒ Google::Protobuf::FieldDescriptorProto::Type
If type_name is set, this need not be set.
-
#type_name ⇒ String
For message and enum types, this is the name of the type.
Methods inherited from Proto
#containing_api, #containing_file, #docs_leading_comments, #leading_comments, #leading_detached_comments, #path, #span, #trailing_comments
Constructor Details
#initialize(descriptor, address, docs, message, enum) ⇒ Field
Initializes a message object.
666 667 668 669 670 |
# File 'lib/gapic/schema/wrappers.rb', line 666 def initialize descriptor, address, docs, , enum super descriptor, address, docs @message = @enum = enum end |
Instance Attribute Details
#enum ⇒ Object
@ return [Enum | nil] The enum if the field is an enum, nil otherwise.
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# File 'lib/gapic/schema/wrappers.rb', line 649 class Field < Proto extend Forwardable attr_accessor :message attr_accessor :enum # Initializes a message object. # @param descriptor [Google::Protobuf::FieldDescriptorProto] 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 message [Message | nil] The message if the field is a message, # nil otherwise. # @param enum [Enum | nil] The enum if the field is an enum, nil # otherwise. def initialize descriptor, address, docs, , enum super descriptor, address, docs @message = @enum = enum end # Whether this field is a message. # @return [Boolean] def return true if @message false end # Whether this field is a repeated field. # @return [Boolean] def repeated? label == Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED end # Whether this field is an enum. # @return [Boolean] def enum? return true if @enum false end # Whether this field is a map # @return [Boolean] def map? return true if repeated? && @message&.map_entry? false end # @return [Field, nil] a key field for this map # or nil if this field is not a map def map_key_field return nil? unless map? @message.fields.find { |f| f.name == "key" } end # @return [Field, nil] a value field for this map # or nil if this field is not a map def map_val_field return nil? unless map? @message.fields.find { |f| f.name == "value" } end # @return [String] A reference to another resource message or resource # definition. See `google/api/resource.proto`. def resource_reference [:".google.api.resource_reference"] if end # @return [Array<Google::Api::FieldBehavior>] A designation of a # specific field behavior (required, output only, etc.) in protobuf # messages. def field_behavior return [:".google.api.field_behavior"] if [] end # @return [String] The full name for this field # (e.g. `google.example.Message.field`). # Useful when matching against other pieces of information # which also reference full proto name. def full_name @address.join "." end # Nonstandard LRO annotation. # This annotation goes on the field of the request message of the method # that intiates a non-standard LRO. # # This annotation contains a field name of the request message # of the LRO polling method. (e.g. `GetRegionOperationRequest`) # (let's call it a 'referenced field') # # When the this method is called, this value should be saved. # Later, when when polling for a nonstandard LRO, this saved value should # be copied to the referenced field. # # This typically would be used for something that a caller method knows, # but an Operation object might not have, e.g. a 'region_id'. # # So if this field is `region_id` and the annotation is # `(google.cloud.operation_request_field) = "region"`, then: # # `get_region_operation_request.region = this_message.region_id` # # In contrast to the `operation_response_field`, this field # - goes onto the fields of the input message of the method that # initiates the LRO # - semantically annotates a 'push': the value of this field gets # 'pushed' into every LRO poll request. # # @return [String] def operation_request_field [:".google.cloud.operation_request_field"] if end # Nonstandard LRO annotation. # This annotation goes on the field of the request message of the method # that polls for a non-standard LRO. # # This annotation contains a field name of the LRO object (typically 'Operation') # (let's call it a 'referenced field') # # When polling for a nonstandard LRO, the value of the field # that this annotation is on should be copied from the referenced field. # # This typically would get used for something that is named differently in the # operation polling request message vs in the Operation object, e.g. operation's name # # So if this field is `operation` and the annotation is # `(google.cloud.operation_response_field) = "name"`, then: # # `get_region_operation_request.operation = operation.name` # # In contrast to the `operation_request_field`, this field # - goes onto the fields of the LRO polling method's input message # - semantically annotates a 'pull', the value of the referenced field gets # 'pulled' into this one. # # @return [String] def operation_response_field [:".google.cloud.operation_response_field"] if end # Nonstandard LRO annotation. # This annotation goes on the fields of the nonstandard Operation message # Is value can be either `NAME`, `STATUS`, `ERROR_MESSAGE`, or `ERROR_CODE` # and the field encodes a corresponding aspect of the LRO behaviour. # # @return [Integer] def operation_field [:".google.cloud.operation_field"] if end # Specifically denotes a field as optional. While all fields in protocol # buffers are optional, this may be specified for emphasis if # appropriate. def optional? field_behavior.include? Google::Api::FieldBehavior::OPTIONAL end # Denotes a field as a part of oneof. # oneof_index is an int field so it'll be 0 by default for every field # and an index in the message's oneof table for the oneof fields # but since the indexes in the message's oneof table start with 0 as well # we need this to determine whether the field is a part of the oneof def oneof? @descriptor.field? :oneof_index end # Denotes a field as required. This indicates that the field **must** be # provided as part of the request, and failure to do so will cause an # error (usually `INVALID_ARGUMENT`). def required? field_behavior.include? Google::Api::FieldBehavior::REQUIRED end # Denotes a field as output only. This indicates that the field is # provided in responses, but including the field in a request does # nothing (the server *must* ignore it and *must not* throw an error as # a result of the field's presence). def output_only? field_behavior.include? Google::Api::FieldBehavior::OUTPUT_ONLY end # Denotes a field as input only. This indicates that the field is # provided in requests, and the corresponding field is not included in # output. def input_only? field_behavior.include? Google::Api::FieldBehavior::INPUT_ONLY end # Denotes a field as immutable. This indicates that the field may be set # once in a request to create a resource, but may not be changed # thereafter. def immutable? field_behavior.include? Google::Api::FieldBehavior::IMMUTABLE end # @!method name # @return [String] the unqualified name of the field. # @!method number # @return [Integer] the number of the field. # @!method label # @return [Google::Protobuf::FieldDescriptorProto::Label] # The label of the field. # @!method type # @return [Google::Protobuf::FieldDescriptorProto::Type] # If type_name is set, this need not be set. If both this and # type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or # TYPE_GROUP. # @!method type_name # @return [String] # For message and enum types, this is the name of the type. If the # name starts with a '.', it is fully-qualified. Otherwise, # C++-like scoping rules are used to find the type (i.e. first the # nested types within this message are searched, then within the # parent, on up to the root namespace). # @!method default_value # @return [String] # For numeric types, contains the original text representation of # the value. For booleans, "true" or "false". For strings, contains # the default text contents (not escaped in any way). For bytes, # contains the C escaped value. All bytes >= 128 are escaped. # @!method oneof_index # @return [Integer] # If set, gives the index of a oneof in the containing type's # oneof_decl list. This field is a member of that oneof. # @!method json_name # @return [String] # JSON name of this field. The value is set by protocol compiler. If # the user has set a "json_name" option on this field, that option's # value will be used. Otherwise, it's deduced from the field's name # by converting it to camelCase. # @!method options # @return [Google::Protobuf::FieldOptions] the options of this field. def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) end |
#message ⇒ Object
@ return [Message | nil] The message if the field is a message, nil otherwise.
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# File 'lib/gapic/schema/wrappers.rb', line 649 class Field < Proto extend Forwardable attr_accessor :message attr_accessor :enum # Initializes a message object. # @param descriptor [Google::Protobuf::FieldDescriptorProto] 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 message [Message | nil] The message if the field is a message, # nil otherwise. # @param enum [Enum | nil] The enum if the field is an enum, nil # otherwise. def initialize descriptor, address, docs, , enum super descriptor, address, docs @message = @enum = enum end # Whether this field is a message. # @return [Boolean] def return true if @message false end # Whether this field is a repeated field. # @return [Boolean] def repeated? label == Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED end # Whether this field is an enum. # @return [Boolean] def enum? return true if @enum false end # Whether this field is a map # @return [Boolean] def map? return true if repeated? && @message&.map_entry? false end # @return [Field, nil] a key field for this map # or nil if this field is not a map def map_key_field return nil? unless map? @message.fields.find { |f| f.name == "key" } end # @return [Field, nil] a value field for this map # or nil if this field is not a map def map_val_field return nil? unless map? @message.fields.find { |f| f.name == "value" } end # @return [String] A reference to another resource message or resource # definition. See `google/api/resource.proto`. def resource_reference [:".google.api.resource_reference"] if end # @return [Array<Google::Api::FieldBehavior>] A designation of a # specific field behavior (required, output only, etc.) in protobuf # messages. def field_behavior return [:".google.api.field_behavior"] if [] end # @return [String] The full name for this field # (e.g. `google.example.Message.field`). # Useful when matching against other pieces of information # which also reference full proto name. def full_name @address.join "." end # Nonstandard LRO annotation. # This annotation goes on the field of the request message of the method # that intiates a non-standard LRO. # # This annotation contains a field name of the request message # of the LRO polling method. (e.g. `GetRegionOperationRequest`) # (let's call it a 'referenced field') # # When the this method is called, this value should be saved. # Later, when when polling for a nonstandard LRO, this saved value should # be copied to the referenced field. # # This typically would be used for something that a caller method knows, # but an Operation object might not have, e.g. a 'region_id'. # # So if this field is `region_id` and the annotation is # `(google.cloud.operation_request_field) = "region"`, then: # # `get_region_operation_request.region = this_message.region_id` # # In contrast to the `operation_response_field`, this field # - goes onto the fields of the input message of the method that # initiates the LRO # - semantically annotates a 'push': the value of this field gets # 'pushed' into every LRO poll request. # # @return [String] def operation_request_field [:".google.cloud.operation_request_field"] if end # Nonstandard LRO annotation. # This annotation goes on the field of the request message of the method # that polls for a non-standard LRO. # # This annotation contains a field name of the LRO object (typically 'Operation') # (let's call it a 'referenced field') # # When polling for a nonstandard LRO, the value of the field # that this annotation is on should be copied from the referenced field. # # This typically would get used for something that is named differently in the # operation polling request message vs in the Operation object, e.g. operation's name # # So if this field is `operation` and the annotation is # `(google.cloud.operation_response_field) = "name"`, then: # # `get_region_operation_request.operation = operation.name` # # In contrast to the `operation_request_field`, this field # - goes onto the fields of the LRO polling method's input message # - semantically annotates a 'pull', the value of the referenced field gets # 'pulled' into this one. # # @return [String] def operation_response_field [:".google.cloud.operation_response_field"] if end # Nonstandard LRO annotation. # This annotation goes on the fields of the nonstandard Operation message # Is value can be either `NAME`, `STATUS`, `ERROR_MESSAGE`, or `ERROR_CODE` # and the field encodes a corresponding aspect of the LRO behaviour. # # @return [Integer] def operation_field [:".google.cloud.operation_field"] if end # Specifically denotes a field as optional. While all fields in protocol # buffers are optional, this may be specified for emphasis if # appropriate. def optional? field_behavior.include? Google::Api::FieldBehavior::OPTIONAL end # Denotes a field as a part of oneof. # oneof_index is an int field so it'll be 0 by default for every field # and an index in the message's oneof table for the oneof fields # but since the indexes in the message's oneof table start with 0 as well # we need this to determine whether the field is a part of the oneof def oneof? @descriptor.field? :oneof_index end # Denotes a field as required. This indicates that the field **must** be # provided as part of the request, and failure to do so will cause an # error (usually `INVALID_ARGUMENT`). def required? field_behavior.include? Google::Api::FieldBehavior::REQUIRED end # Denotes a field as output only. This indicates that the field is # provided in responses, but including the field in a request does # nothing (the server *must* ignore it and *must not* throw an error as # a result of the field's presence). def output_only? field_behavior.include? Google::Api::FieldBehavior::OUTPUT_ONLY end # Denotes a field as input only. This indicates that the field is # provided in requests, and the corresponding field is not included in # output. def input_only? field_behavior.include? Google::Api::FieldBehavior::INPUT_ONLY end # Denotes a field as immutable. This indicates that the field may be set # once in a request to create a resource, but may not be changed # thereafter. def immutable? field_behavior.include? Google::Api::FieldBehavior::IMMUTABLE end # @!method name # @return [String] the unqualified name of the field. # @!method number # @return [Integer] the number of the field. # @!method label # @return [Google::Protobuf::FieldDescriptorProto::Label] # The label of the field. # @!method type # @return [Google::Protobuf::FieldDescriptorProto::Type] # If type_name is set, this need not be set. If both this and # type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or # TYPE_GROUP. # @!method type_name # @return [String] # For message and enum types, this is the name of the type. If the # name starts with a '.', it is fully-qualified. Otherwise, # C++-like scoping rules are used to find the type (i.e. first the # nested types within this message are searched, then within the # parent, on up to the root namespace). # @!method default_value # @return [String] # For numeric types, contains the original text representation of # the value. For booleans, "true" or "false". For strings, contains # the default text contents (not escaped in any way). For bytes, # contains the C escaped value. All bytes >= 128 are escaped. # @!method oneof_index # @return [Integer] # If set, gives the index of a oneof in the containing type's # oneof_decl list. This field is a member of that oneof. # @!method json_name # @return [String] # JSON name of this field. The value is set by protocol compiler. If # the user has set a "json_name" option on this field, that option's # value will be used. Otherwise, it's deduced from the field's name # by converting it to camelCase. # @!method options # @return [Google::Protobuf::FieldOptions] the options of this field. def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) end |
Instance Method Details
#default_value ⇒ String
Returns For numeric types, contains the original text representation of the value. For booleans, "true" or "false". For strings, contains the default text contents (not escaped in any way). For bytes, contains the C escaped value. All bytes >= 128 are escaped.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#enum? ⇒ Boolean
Whether this field is an enum.
688 689 690 691 692 |
# File 'lib/gapic/schema/wrappers.rb', line 688 def enum? return true if @enum false end |
#field_behavior ⇒ Array<Google::Api::FieldBehavior>
Returns A designation of a specific field behavior (required, output only, etc.) in protobuf messages.
725 726 727 728 729 |
# File 'lib/gapic/schema/wrappers.rb', line 725 def field_behavior return [:".google.api.field_behavior"] if [] end |
#full_name ⇒ String
Returns The full name for this field
(e.g. google.example.Message.field).
Useful when matching against other pieces of information
which also reference full proto name.
735 736 737 |
# File 'lib/gapic/schema/wrappers.rb', line 735 def full_name @address.join "." end |
#immutable? ⇒ Boolean
Denotes a field as immutable. This indicates that the field may be set once in a request to create a resource, but may not be changed thereafter.
849 850 851 |
# File 'lib/gapic/schema/wrappers.rb', line 849 def immutable? field_behavior.include? Google::Api::FieldBehavior::IMMUTABLE end |
#input_only? ⇒ Boolean
Denotes a field as input only. This indicates that the field is provided in requests, and the corresponding field is not included in output.
842 843 844 |
# File 'lib/gapic/schema/wrappers.rb', line 842 def input_only? field_behavior.include? Google::Api::FieldBehavior::INPUT_ONLY end |
#json_name ⇒ String
Returns JSON name of this field. The value is set by protocol compiler. If the user has set a "json_name" option on this field, that option's value will be used. Otherwise, it's deduced from the field's name by converting it to camelCase.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#label ⇒ Google::Protobuf::FieldDescriptorProto::Label
Returns The label of the field.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#map? ⇒ Boolean
Whether this field is a map
696 697 698 699 700 |
# File 'lib/gapic/schema/wrappers.rb', line 696 def map? return true if repeated? && @message&.map_entry? false end |
#map_key_field ⇒ Field?
Returns a key field for this map or nil if this field is not a map.
704 705 706 707 |
# File 'lib/gapic/schema/wrappers.rb', line 704 def map_key_field return nil? unless map? @message.fields.find { |f| f.name == "key" } end |
#map_val_field ⇒ Field?
Returns a value field for this map or nil if this field is not a map.
711 712 713 714 |
# File 'lib/gapic/schema/wrappers.rb', line 711 def map_val_field return nil? unless map? @message.fields.find { |f| f.name == "value" } end |
#message? ⇒ Boolean
Whether this field is a message.
674 675 676 677 678 |
# File 'lib/gapic/schema/wrappers.rb', line 674 def return true if @message false end |
#name ⇒ String
Returns the unqualified name of the field.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#number ⇒ Integer
Returns the number of the field.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#oneof? ⇒ Boolean
Denotes a field as a part of oneof. oneof_index is an int field so it'll be 0 by default for every field and an index in the message's oneof table for the oneof fields but since the indexes in the message's oneof table start with 0 as well we need this to determine whether the field is a part of the oneof
820 821 822 |
# File 'lib/gapic/schema/wrappers.rb', line 820 def oneof? @descriptor.field? :oneof_index end |
#oneof_index ⇒ Integer
Returns If set, gives the index of a oneof in the containing type's oneof_decl list. This field is a member of that oneof.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#operation_field ⇒ Integer
Nonstandard LRO annotation.
This annotation goes on the fields of the nonstandard Operation message
Is value can be either NAME, STATUS, ERROR_MESSAGE, or ERROR_CODE
and the field encodes a corresponding aspect of the LRO behaviour.
804 805 806 |
# File 'lib/gapic/schema/wrappers.rb', line 804 def operation_field [:".google.cloud.operation_field"] if end |
#operation_request_field ⇒ String
Nonstandard LRO annotation. This annotation goes on the field of the request message of the method that intiates a non-standard LRO.
This annotation contains a field name of the request message
of the LRO polling method. (e.g. GetRegionOperationRequest)
(let's call it a 'referenced field')
When the this method is called, this value should be saved. Later, when when polling for a nonstandard LRO, this saved value should be copied to the referenced field.
This typically would be used for something that a caller method knows, but an Operation object might not have, e.g. a 'region_id'.
So if this field is region_id and the annotation is
(google.cloud.operation_request_field) = "region", then:
`get_region_operation_request.region = this_message.region_id`
In contrast to the operation_response_field, this field
- goes onto the fields of the input message of the method that initiates the LRO
- semantically annotates a 'push': the value of this field gets 'pushed' into every LRO poll request.
766 767 768 |
# File 'lib/gapic/schema/wrappers.rb', line 766 def operation_request_field [:".google.cloud.operation_request_field"] if end |
#operation_response_field ⇒ String
Nonstandard LRO annotation. This annotation goes on the field of the request message of the method that polls for a non-standard LRO.
This annotation contains a field name of the LRO object (typically 'Operation') (let's call it a 'referenced field')
When polling for a nonstandard LRO, the value of the field that this annotation is on should be copied from the referenced field.
This typically would get used for something that is named differently in the operation polling request message vs in the Operation object, e.g. operation's name
So if this field is operation and the annotation is
(google.cloud.operation_response_field) = "name", then:
`get_region_operation_request.operation = operation.name`
In contrast to the operation_request_field, this field
- goes onto the fields of the LRO polling method's input message
- semantically annotates a 'pull', the value of the referenced field gets 'pulled' into this one.
794 795 796 |
# File 'lib/gapic/schema/wrappers.rb', line 794 def operation_response_field [:".google.cloud.operation_response_field"] if end |
#optional? ⇒ Boolean
Specifically denotes a field as optional. While all fields in protocol buffers are optional, this may be specified for emphasis if appropriate.
811 812 813 |
# File 'lib/gapic/schema/wrappers.rb', line 811 def optional? field_behavior.include? Google::Api::FieldBehavior::OPTIONAL end |
#options ⇒ Google::Protobuf::FieldOptions
Returns the options of this field.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#output_only? ⇒ Boolean
Denotes a field as output only. This indicates that the field is provided in responses, but including the field in a request does nothing (the server must ignore it and must not throw an error as a result of the field's presence).
835 836 837 |
# File 'lib/gapic/schema/wrappers.rb', line 835 def output_only? field_behavior.include? Google::Api::FieldBehavior::OUTPUT_ONLY end |
#repeated? ⇒ Boolean
Whether this field is a repeated field.
682 683 684 |
# File 'lib/gapic/schema/wrappers.rb', line 682 def repeated? label == Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED end |
#required? ⇒ Boolean
Denotes a field as required. This indicates that the field must be
provided as part of the request, and failure to do so will cause an
error (usually INVALID_ARGUMENT).
827 828 829 |
# File 'lib/gapic/schema/wrappers.rb', line 827 def required? field_behavior.include? Google::Api::FieldBehavior::REQUIRED end |
#resource_reference ⇒ String
Returns A reference to another resource message or resource
definition. See google/api/resource.proto.
718 719 720 |
# File 'lib/gapic/schema/wrappers.rb', line 718 def resource_reference [:".google.api.resource_reference"] if end |
#type ⇒ Google::Protobuf::FieldDescriptorProto::Type
Returns If type_name is set, this need not be set. If both this and type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |
#type_name ⇒ String
Returns For message and enum types, this is the name of the type. If the name starts with a '.', it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).
890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/gapic/schema/wrappers.rb', line 890 def_delegators( :descriptor, :name, :number, :label, :type, :type_name, :default_value, :oneof_index, :json_name, :options, :proto3_optional? ) |