MessageTransform

All supported message transforms types.

JSON representation
{
  "enabled": boolean,
  "disabled": boolean,

  // Union field transform can be only one of the following:
  "javascriptUdf": {
    object (JavaScriptUDF)
  },
  "aiInference": {
    object (AIInference)
  }
  // End of list of possible types for union field transform.
}
Fields
enabled
(deprecated)

boolean

Optional. This field is deprecated, use the disabled field to disable transforms.

disabled

boolean

Optional. If true, the transform is disabled and will not be applied to messages. Defaults to false.

Union field transform. The type of transform to apply to messages. transform can be only one of the following:
javascriptUdf

object (JavaScriptUDF)

Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's are specified on a resource, each must have a unique functionName.

aiInference

object (AIInference)

Optional. AI Inference. Specifies the Vertex AI endpoint that inference requests built from the Pub/Sub message data and provided parameters will be sent to.

JavaScriptUDF

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

JSON representation
{
  "functionName": string,
  "code": string
}
Fields
functionName

string

Required. Name of the JavasScript function that should applied to Pub/Sub messages.

code

string

Required. JavaScript code that contains a function functionName with the below signature:

  /**
  * Transforms a Pub/Sub message.

  * @return {(Object<string, (string | Object<string, string>)>|null)} - To
  * filter a message, return `null`. To transform a message return a map
  * with the following keys:
  *   - (required) 'data' : {string}
  *   - (optional) 'attributes' : {Object<string, string>}
  * Returning empty `attributes` will remove all attributes from the
  * message.
  *
  * @param  {(Object<string, (string | Object<string, string>)>} Pub/Sub
  * message. Keys:
  *   - (required) 'data' : {string}
  *   - (required) 'attributes' : {Object<string, string>}
  *
  * @param  {Object<string, any>} metadata - Pub/Sub message metadata.
  * Keys:
  *   - (optional) 'messageId'  : {string}
  *   - (optional) 'publishTime': {string} YYYY-MM-DDTHH:MM:SSZ format
  *   - (optional) 'orderingKey': {string}
  */

  function <functionName>(message, metadata) {
  }

AIInference

Configuration for making inference requests against Vertex AI models.

JSON representation
{
  "endpoint": string,
  "serviceAccountEmail": string,

  // Union field inference_mode can be only one of the following:
  "unstructuredInference": {
    object (UnstructuredInference)
  }
  // End of list of possible types for union field inference_mode.
}
Fields
endpoint

string

Required. An endpoint to a Vertex AI model of the form projects/{project}/locations/{location}/endpoints/{endpoint} or projects/{project}/locations/{location}/publishers/{publisher}/models/{model}. Vertex AI API requests will be sent to this endpoint.

serviceAccountEmail

string

Optional. The service account to use to make prediction requests against endpoints. The resource creator or updater that specifies this field must have iam.serviceAccounts.actAs permission on the service account. If not specified, the Pub/Sub service agent, service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.

Union field inference_mode. The format of inference requests made to the endpoint. inference_mode can be only one of the following:
unstructuredInference

object (UnstructuredInference)

Optional. Requests and responses can be any arbitrary JSON object.

UnstructuredInference

Configuration for making inferences using arbitrary JSON payloads.

JSON representation
{
  "parameters": {
    object
  }
}
Fields
parameters

object (Struct format)

Optional. A parameters object to be included in each inference request. The parameters object is combined with the data field of the Pub/Sub message to form the inference request.