Class: Google::Apis::PubsubV1::JavaScriptUdf

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/pubsub_v1/classes.rb,
lib/google/apis/pubsub_v1/representations.rb,
lib/google/apis/pubsub_v1/representations.rb

Overview

User-defined JavaScript function that can transform or filter a Pub/Sub message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ JavaScriptUdf

Returns a new instance of JavaScriptUdf.



967
968
969
# File 'lib/google/apis/pubsub_v1/classes.rb', line 967

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#codeString

Required. JavaScript code that contains a function function_name with the below signature: ``/** * Transforms a Pub/Sub message. * @return(Object)>| null)- To * filter a message, returnnull. To transform a message return a map * with the following keys: * - (required) 'data' :string* - (optional) 'attributes' :Object* Returning emptyattributeswill remove all attributes from the * message. * * @param(Object)>` Pub/Sub * message. Keys:

  • - (required) 'data' : string * - (required) 'attributes' : Object * * @ param Object metadata - Pub/Sub message metadata. * Keys: * - (optional) ' message_id' : string * - (optional) 'publish_time': string YYYY-MM-DDTHH: MM:SSZ format * - (optional) 'ordering_key': string */ function (message, metadata) `` Corresponds to the JSON propertycode`

Returns:

  • (String)


959
960
961
# File 'lib/google/apis/pubsub_v1/classes.rb', line 959

def code
  @code
end

#function_nameString

Required. Name of the JavasScript function that should applied to Pub/Sub messages. Corresponds to the JSON property functionName

Returns:

  • (String)


965
966
967
# File 'lib/google/apis/pubsub_v1/classes.rb', line 965

def function_name
  @function_name
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



972
973
974
975
# File 'lib/google/apis/pubsub_v1/classes.rb', line 972

def update!(**args)
  @code = args[:code] if args.key?(:code)
  @function_name = args[:function_name] if args.key?(:function_name)
end