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. 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.

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

Parameters:

  • code (Integer) (defaults to: OMIT) —

    The status code, which should be an enum value of [google.rpc.Code][google.rpc.code].

  • message (String) (defaults to: OMIT) —

    A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.status.details] field, or localized by the client.

  • details (Array<SSOReady::GoogleProtobufAny>) (defaults to: OMIT) —

    A list of messages that carry the error details. There is a common set of message types for APIs to use.

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



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_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#code ⇒ Integer (readonly)

Returns The status code, which should be an enum value of [google.rpc.Code][google.rpc.code].

Returns:

  • (Integer) —

    The status code, which should be an enum value of [google.rpc.Code][google.rpc.code].



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

def code
  @code
end

#details ⇒ Array<SSOReady::GoogleProtobufAny> (readonly)

Returns A list of messages that carry the error details. There is a common set of message types for APIs to use.

Returns:

  • (Array<SSOReady::GoogleProtobufAny>) —

    A list of messages that carry the error details. There is a common set of message types for APIs to use.



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

def details
  @details
end

#message ⇒ String (readonly)

Returns A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.status.details] field, or localized by the client.

Returns:

  • (String) —

    A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.status.details] field, or localized by the client.



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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

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