Class: Shipeasy::Admin::Generated::ListGatesResponseDataInnerStackInnerOneOf

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb

Overview

Rule-based sub-gate. When the rules match and the caller falls in the per-condition rollout bucket, evaluation short-circuits and the gate returns true; otherwise it falls through to the next entry.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ ListGatesResponseDataInnerStackInnerOneOf

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 126

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Shipeasy::Admin::Generated::ListGatesResponseDataInnerStackInnerOneOf` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Shipeasy::Admin::Generated::ListGatesResponseDataInnerStackInnerOneOf`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  else
    self.type = nil
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'from_template')
    self.from_template = attributes[:'from_template']
  end

  if attributes.key?(:'pass')
    self.pass = attributes[:'pass']
  end

  if attributes.key?(:'rules')
    if (value = attributes[:'rules']).is_a?(Array)
      self.rules = value
    end
  end

  if attributes.key?(:'rollout_pct')
    self.rollout_pct = attributes[:'rollout_pct']
  end

  if attributes.key?(:'bucket_by')
    self.bucket_by = attributes[:'bucket_by']
  end

  if attributes.key?(:'salt')
    self.salt = attributes[:'salt']
  end

  if attributes.key?(:'ramp')
    self.ramp = attributes[:'ramp']
  end

  if attributes.key?(:'locked')
    self.locked = attributes[:'locked']
  end
end

Instance Attribute Details

#bucket_byObject

Attribute used to hash the caller into the per-condition bucket. Default userID.



41
42
43
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 41

def bucket_by
  @bucket_by
end

#from_templateObject

Id of the project template this entry was seeded from, or null if hand-authored.



29
30
31
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 29

def from_template
  @from_template
end

#idObject

Client-supplied stable id for the stack entry (used for React keys, audit diffs, and as the default per-condition rollout salt).



20
21
22
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 20

def id
  @id
end

#lockedObject

If true, dashboard hides edit controls (e.g. the trailing public-floor entry).



49
50
51
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 49

def locked
  @locked
end

#nameObject

Human label shown in the dashboard.



26
27
28
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 26

def name
  @name
end

#passObject

Combinator across rules. all = AND (default), any = OR.



32
33
34
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 32

def pass
  @pass
end

#rampObject

Returns the value of attribute ramp.



46
47
48
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 46

def ramp
  @ramp
end

#rollout_pctObject

Per-condition rollout in basis points. After the rules match, the caller is bucketed at this %; in-bucket → gate true, otherwise fall through to the next entry. Absent ⇒ 10000 (100%, every matching caller passes).



38
39
40
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 38

def rollout_pct
  @rollout_pct
end

#rulesObject

Predicates evaluated under pass. Empty array = match nothing.



35
36
37
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 35

def rules
  @rules
end

#saltObject

Per-condition hash salt. Defaults to the entry id, then the gate salt.



44
45
46
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 44

def salt
  @salt
end

#typeObject

Discriminator. condition = rule-based predicate sub-gate.



23
24
25
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 23

def type
  @type
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



91
92
93
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 91

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



96
97
98
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 96

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 74

def self.attribute_map
  {
    :'id' => :'id',
    :'type' => :'type',
    :'name' => :'name',
    :'from_template' => :'fromTemplate',
    :'pass' => :'pass',
    :'rules' => :'rules',
    :'rollout_pct' => :'rolloutPct',
    :'bucket_by' => :'bucketBy',
    :'salt' => :'salt',
    :'ramp' => :'ramp',
    :'locked' => :'locked'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 320

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



118
119
120
121
122
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 118

def self.openapi_nullable
  Set.new([
    :'from_template',
  ])
end

.openapi_typesObject

Attribute type mapping.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 101

def self.openapi_types
  {
    :'id' => :'String',
    :'type' => :'String',
    :'name' => :'String',
    :'from_template' => :'String',
    :'pass' => :'String',
    :'rules' => :'Array<ListGatesResponseDataInnerRulesInner>',
    :'rollout_pct' => :'Integer',
    :'bucket_by' => :'String',
    :'salt' => :'String',
    :'ramp' => :'ListGatesResponseDataInnerStackInnerOneOfRamp',
    :'locked' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 289

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      type == o.type &&
      name == o.name &&
      from_template == o.from_template &&
      pass == o.pass &&
      rules == o.rules &&
      rollout_pct == o.rollout_pct &&
      bucket_by == o.bucket_by &&
      salt == o.salt &&
      ramp == o.ramp &&
      locked == o.locked
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


307
308
309
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 307

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



313
314
315
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 313

def hash
  [id, type, name, from_template, pass, rules, rollout_pct, bucket_by, salt, ramp, locked].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 193

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @id.to_s.length < 1
    invalid_properties.push('invalid value for "id", the character length must be greater than or equal to 1.')
  end

  if @type.nil?
    invalid_properties.push('invalid value for "type", type cannot be nil.')
  end

  if !@rollout_pct.nil? && @rollout_pct > 10000
    invalid_properties.push('invalid value for "rollout_pct", must be smaller than or equal to 10000.')
  end

  if !@rollout_pct.nil? && @rollout_pct < 0
    invalid_properties.push('invalid value for "rollout_pct", must be greater than or equal to 0.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 342

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb', line 221

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @id.to_s.length < 1
  return false if @type.nil?
  type_validator = EnumAttributeValidator.new('String', ["condition"])
  return false unless type_validator.valid?(@type)
  pass_validator = EnumAttributeValidator.new('String', ["all", "any"])
  return false unless pass_validator.valid?(@pass)
  return false if !@rollout_pct.nil? && @rollout_pct > 10000
  return false if !@rollout_pct.nil? && @rollout_pct < 0
  true
end