OptionsUtil

OptionsUtil

A utility class for formatting known and raw options into the proto structure utilized by Pipelines.

Constructor

new OptionsUtil()

Example
```
myUtil = new OptionsUtil({
    someFoo: {
      serverName: 'some_foo',
    },
    aBar: {
      serverName: 'a_bar',
      nestedOptions: {
        baz: {
          serverName: 'baz',
        }
      },
    },
  });

optionsProto = myUtil.getOptionsProto(
   serializer,
   {
     someFoo: 1
   },
   {
     aBar.another_unknown_option: "yep"
   });

// Resulting optionsProto:
// {
//    'some_foo': { integerValue: 1 },
//    'a_bar': { mapValue: { fields: { 'another_unknown_option': {stringValue: 'yep' }}}}
// }
```

Methods

getOptionsProto(serializer, knownOptions, optionsOverride)

Serialize known and raw options to a proto object.

  • Renames knownOptions from the SDK name (camel case) to server name (snake case)
  • Serializes values provided for each option to a proto value, using the provided serializer.
  • Overlays optionsOverrides (which represent raw options) onto the result proto.
  • Supports nested objects ({optionA: { optionB: true }}) and dot notation ({optionA.optionB: true}).
Parameters:
Name Type Description
serializer
knownOptions
optionsOverride