Class: NewStoreApi::JobResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/job_response.rb

Overview

Response model for job operations.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(created_at = nil, dataset = nil, job_id = nil, status = nil, tenant = nil, error_message = SKIP, error_reason = SKIP, signed_urls = SKIP) ⇒ JobResponse

Returns a new instance of JobResponse.



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/new_store_api/models/job_response.rb', line 74

def initialize(created_at = nil, dataset = nil, job_id = nil, status = nil,
               tenant = nil, error_message = SKIP, error_reason = SKIP,
               signed_urls = SKIP)
  @created_at = created_at
  @dataset = dataset
  @error_message = error_message unless error_message == SKIP
  @error_reason = error_reason unless error_reason == SKIP
  @job_id = job_id
  @signed_urls = signed_urls unless signed_urls == SKIP
  @status = status
  @tenant = tenant
end

Instance Attribute Details

#created_atDateTime

Job creation timestamp (ISO 8601 format)

Returns:

  • (DateTime)


15
16
17
# File 'lib/new_store_api/models/job_response.rb', line 15

def created_at
  @created_at
end

#datasetString

Dataset identifier

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/job_response.rb', line 19

def dataset
  @dataset
end

#error_messageObject

Detailed error message from BigQuery (only present if job failed)

Returns:

  • (Object)


23
24
25
# File 'lib/new_store_api/models/job_response.rb', line 23

def error_message
  @error_message
end

#error_reasonObject

Error reason/code from BigQuery (only present if job failed)

Returns:

  • (Object)


27
28
29
# File 'lib/new_store_api/models/job_response.rb', line 27

def error_reason
  @error_reason
end

#job_idString

Unique job identifier

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/job_response.rb', line 31

def job_id
  @job_id
end

#signed_urlsObject

List of signed URLs for downloading results (deprecated - use /download endpoint instead)

Returns:

  • (Object)


36
37
38
# File 'lib/new_store_api/models/job_response.rb', line 36

def signed_urls
  @signed_urls
end

#statusString

Current job status

Returns:

  • (String)


40
41
42
# File 'lib/new_store_api/models/job_response.rb', line 40

def status
  @status
end

#tenantString

Tenant identifier

Returns:

  • (String)


44
45
46
# File 'lib/new_store_api/models/job_response.rb', line 44

def tenant
  @tenant
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/new_store_api/models/job_response.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  dataset = hash.key?('dataset') ? hash['dataset'] : nil
  job_id = hash.key?('job_id') ? hash['job_id'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  tenant = hash.key?('tenant') ? hash['tenant'] : nil
  error_message = hash.key?('error_message') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:JobResponseErrorMessage), hash['error_message']
  ) : SKIP
  error_reason = hash.key?('error_reason') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:JobResponseErrorReason), hash['error_reason']
  ) : SKIP
  signed_urls = hash.key?('signed_urls') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:JobResponseSignedUrls), hash['signed_urls']
  ) : SKIP

  # Create object from extracted values.
  JobResponse.new(created_at,
                  dataset,
                  job_id,
                  status,
                  tenant,
                  error_message,
                  error_reason,
                  signed_urls)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/new_store_api/models/job_response.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_at'] = 'created_at'
  @_hash['dataset'] = 'dataset'
  @_hash['error_message'] = 'error_message'
  @_hash['error_reason'] = 'error_reason'
  @_hash['job_id'] = 'job_id'
  @_hash['signed_urls'] = 'signed_urls'
  @_hash['status'] = 'status'
  @_hash['tenant'] = 'tenant'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/new_store_api/models/job_response.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
# File 'lib/new_store_api/models/job_response.rb', line 61

def self.optionals
  %w[
    error_message
    error_reason
    signed_urls
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (JobResponse | Hash)

    value against the validation is performed.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/new_store_api/models/job_response.rb', line 126

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.created_at,
                            ->(val) { val.instance_of? DateTime }) and
        APIHelper.valid_type?(value.dataset,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.job_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.status,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.tenant,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['created_at'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['dataset'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['job_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['status'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['tenant'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



167
168
169
170
171
172
173
# File 'lib/new_store_api/models/job_response.rb', line 167

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at.inspect}, dataset: #{@dataset.inspect},"\
  " error_message: #{@error_message.inspect}, error_reason: #{@error_reason.inspect}, job_id:"\
  " #{@job_id.inspect}, signed_urls: #{@signed_urls.inspect}, status: #{@status.inspect},"\
  " tenant: #{@tenant.inspect}>"
end

#to_custom_created_atObject



120
121
122
# File 'lib/new_store_api/models/job_response.rb', line 120

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



159
160
161
162
163
164
# File 'lib/new_store_api/models/job_response.rb', line 159

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at}, dataset: #{@dataset}, error_message:"\
  " #{@error_message}, error_reason: #{@error_reason}, job_id: #{@job_id}, signed_urls:"\
  " #{@signed_urls}, status: #{@status}, tenant: #{@tenant}>"
end