Class: SSOReady::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/ssoready/types/status.rb

Overview

The ‘Status` type defines a logical error model that is suitable for different

programming environments, including REST APIs and RPC APIs. It is used by
[gRPC](https://github.com/grpc). Each `Status` message contains three pieces of
data: error code, error message, and error details. You can find out more about
this error model and how to work with it in the [API Design
Guide](https://cloud.google.com/apis/design/errors).

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: OMIT, message: OMIT, details: OMIT, additional_properties: nil) ⇒ SSOReady::Status



44
45
46
47
48
49
50
51
52
# File 'lib/ssoready/types/status.rb', line 44

def initialize(code: OMIT, message: OMIT, details: OMIT, additional_properties: nil)
  @code = code if code != OMIT
  @message = message if message != OMIT
  @details = details if details != OMIT
  @additional_properties = additional_properties
  @_field_set = { "code": code, "message": message, "details": details }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



27
28
29
# File 'lib/ssoready/types/status.rb', line 27

def additional_properties
  @additional_properties
end

#codeInteger (readonly)



17
18
19
# File 'lib/ssoready/types/status.rb', line 17

def code
  @code
end

#detailsArray<SSOReady::GoogleProtobufAny> (readonly)



25
26
27
# File 'lib/ssoready/types/status.rb', line 25

def details
  @details
end

#messageString (readonly)



22
23
24
# File 'lib/ssoready/types/status.rb', line 22

def message
  @message
end

Class Method Details

.from_json(json_object:) ⇒ SSOReady::Status

Deserialize a JSON object to an instance of Status



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ssoready/types/status.rb', line 58

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  code = parsed_json["code"]
  message = parsed_json["message"]
  details = parsed_json["details"]&.map do |item|
    item = item.to_json
    SSOReady::GoogleProtobufAny.from_json(json_object: item)
  end
  new(
    code: code,
    message: message,
    details: details,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


88
89
90
91
92
# File 'lib/ssoready/types/status.rb', line 88

def self.validate_raw(obj:)
  obj.code&.is_a?(Integer) != false || raise("Passed value for field obj.code is not the expected type, validation failed.")
  obj.message&.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
  obj.details&.is_a?(Array) != false || raise("Passed value for field obj.details is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Status to a JSON object



78
79
80
# File 'lib/ssoready/types/status.rb', line 78

def to_json(*_args)
  @_field_set&.to_json
end