Class: Api2Convert::Model::OutputTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/api2convert/model/output_target.rb

Overview

A cloud-storage delivery target for a conversion's output: { type:<provider>, parameters, credentials }.

Attach one (or more) to a conversion via client.convert(..., output_targets: [...]) / convert_async(...), or inline in a raw jobs.create conversion map. When any output target is set the conversion delivers straight to your storage and produces no local output — so convert returns the completed job without downloading.

This wave ships the generic shape only (type + free-form parameters/credentials); the per-provider output keys live in a separate service and diverge per provider, so there are no per-provider output factories yet.

Serialization (#to_h) emits { type, parameters, credentials } and omits status (server-set, read-only). On read (OutputTarget.from_hash) type, parameters and status round-trip as raw values; credentials are never surfaced (the API returns them empty). credentials ride in the plaintext body, so #inspect masks the whole object to [REDACTED].

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, parameters: {}, credentials: {}, status: nil) ⇒ OutputTarget

status is server-set on read (waiting|uploading|completed|failed) and never sent on create.



29
30
31
32
33
34
35
# File 'lib/api2convert/model/output_target.rb', line 29

def initialize(type:, parameters: {}, credentials: {}, status: nil)
  @type = type
  @parameters = parameters
  @credentials = credentials
  @status = status
  freeze
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



25
26
27
# File 'lib/api2convert/model/output_target.rb', line 25

def credentials
  @credentials
end

#parametersObject (readonly)

Returns the value of attribute parameters.



25
26
27
# File 'lib/api2convert/model/output_target.rb', line 25

def parameters
  @parameters
end

#statusObject (readonly)

Returns the value of attribute status.



25
26
27
# File 'lib/api2convert/model/output_target.rb', line 25

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/api2convert/model/output_target.rb', line 25

def type
  @type
end

Class Method Details

.from_hash(data) ⇒ Object

Hydrate from a GET /jobs/{id} output_target[] element. type/status stay raw strings (an unknown provider round-trips untyped); credentials are deliberately not surfaced.



56
57
58
59
60
61
62
63
64
# File 'lib/api2convert/model/output_target.rb', line 56

def self.from_hash(data)
  d = Support::Data.as_object(data)
  new(
    type: Support::Data.as_str(d["type"]),
    parameters: Support::Data.as_object(d["parameters"]),
    credentials: {},
    status: Support::Data.nullable_str(d["status"])
  )
end

.of(type, parameters: {}, credentials: {}) ⇒ Object

Generic constructor accepting a CloudProvider constant or a forward-compat string.



39
40
41
# File 'lib/api2convert/model/output_target.rb', line 39

def self.of(type, parameters: {}, credentials: {})
  new(type: type.to_s, parameters: parameters, credentials: credentials)
end

Instance Method Details

#inspectObject

Redacted representation — credentials masked. Safe to log.



67
68
69
70
71
# File 'lib/api2convert/model/output_target.rb', line 67

def inspect
  "#<#{self.class.name} type=#{@type.inspect} " \
    "parameters=#{Support::Redactor.parameters(@parameters).inspect} " \
    "credentials=#{Support::Redactor::MARKER} status=#{@status.inspect}>"
end

#to_hObject

The wire descriptor sent on create — { type, parameters, credentials }, with status omitted (server-set, read-only).



45
46
47
48
49
50
51
# File 'lib/api2convert/model/output_target.rb', line 45

def to_h
  {
    "type" => @type,
    "parameters" => @parameters,
    "credentials" => @credentials
  }
end

#to_sObject



73
74
75
# File 'lib/api2convert/model/output_target.rb', line 73

def to_s
  inspect
end