Class: Fluent::BigQueryOutput::FieldSchema
- Inherits:
-
Object
- Object
- Fluent::BigQueryOutput::FieldSchema
- Defined in:
- lib/fluent/plugin/out_bigquery.rb
Overview
def client_oauth # not implemented raise NotImplementedError, "OAuth needs browser authentication..."
client = Google::APIClient.new(
:application_name => 'Example Ruby application',
:application_version => '1.0.0'
)
bigquery = client.discovered_api('bigquery', 'v2')
flow = Google::APIClient::InstalledAppFlow.new(
:client_id => @client_id
:client_secret => @client_secret
:scope => ['https://www.googleapis.com/auth/bigquery']
)
client.authorization = flow.authorize # browser authentication !
client
end
Direct Known Subclasses
BooleanFieldSchema, FloatFieldSchema, IntegerFieldSchema, RecordSchema, StringFieldSchema, TimestampFieldSchema
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #format(value) ⇒ Object
- #format_one(value) ⇒ Object
-
#initialize(name, mode = :nullable) ⇒ FieldSchema
constructor
A new instance of FieldSchema.
Constructor Details
#initialize(name, mode = :nullable) ⇒ FieldSchema
Returns a new instance of FieldSchema.
323 324 325 326 327 328 329 330 |
# File 'lib/fluent/plugin/out_bigquery.rb', line 323 def initialize(name, mode = :nullable) unless [:nullable, :required, :repeated].include?(mode) raise ConfigError, "Unrecognized mode for #{name}: #{mode}" end @name = name @mode = mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
332 333 334 |
# File 'lib/fluent/plugin/out_bigquery.rb', line 332 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
332 333 334 |
# File 'lib/fluent/plugin/out_bigquery.rb', line 332 def name @name end |
Instance Method Details
#format(value) ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/fluent/plugin/out_bigquery.rb', line 334 def format(value) case @mode when :nullable format_one(value) unless value.nil? when :required raise "Required field #{name} cannot be null" if value.nil? format_one(value) when :repeated value.nil? ? [] : value.map {|v| format_one(v) } end end |
#format_one(value) ⇒ Object
346 347 348 |
# File 'lib/fluent/plugin/out_bigquery.rb', line 346 def format_one(value) raise NotImplementedError, "Must implement in a subclass" end |