Class: Shipeasy::Admin::Generated::ListGatesResponseDataInnerStackInnerOneOf1

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

Overview

Percentage-rollout sub-gate. Hashes bucketBy (default userID) with salt and returns true for rolloutPct/10000 fraction of callers (or the ramp's effective % when ramp is set).

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 = {}) ⇒ ListGatesResponseDataInnerStackInnerOneOf1

Initializes the object

Parameters:

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

    Model attributes in the form of hash



116
117
118
119
120
121
122
123
124
125
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
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 116

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Shipeasy::Admin::Generated::ListGatesResponseDataInnerStackInnerOneOf1` 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::ListGatesResponseDataInnerStackInnerOneOf1`. 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?(:'rollout_pct')
    self.rollout_pct = attributes[:'rollout_pct']
  else
    self.rollout_pct = nil
  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 a bucket. Defaults to user.userID. Use e.g. accountID to bucket whole accounts together.



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

def bucket_by
  @bucket_by
end

#from_templateObject

Source template id, or null.



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

def from_template
  @from_template
end

#idObject

Client-supplied stable id for the stack entry.



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

def id
  @id
end

#lockedObject

If true, dashboard hides edit controls.



43
44
45
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 43

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_of1.rb', line 26

def name
  @name
end

#rampObject

Returns the value of attribute ramp.



40
41
42
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 40

def ramp
  @ramp
end

#rollout_pctObject

Bucket size in basis points (0–10000 = 0%–100%). 5000 = 50%, 100 = 1%, allows sub-1% precision.



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

def rollout_pct
  @rollout_pct
end

#saltObject

Per-entry hash salt. Defaults to the gate's salt. Set explicitly to keep two rollouts independent or correlated across gates.



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

def salt
  @salt
end

#typeObject

Discriminator. rollout = percentage-bucket sub-gate.



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

def type
  @type
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



83
84
85
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 83

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



88
89
90
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 88

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 68

def self.attribute_map
  {
    :'id' => :'id',
    :'type' => :'type',
    :'name' => :'name',
    :'from_template' => :'fromTemplate',
    :'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



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 293

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



108
109
110
111
112
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 108

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

.openapi_typesObject

Attribute type mapping.



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 93

def self.openapi_types
  {
    :'id' => :'String',
    :'type' => :'String',
    :'name' => :'String',
    :'from_template' => :'String',
    :'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



264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 264

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


280
281
282
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 280

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



286
287
288
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 286

def hash
  [id, type, name, from_template, 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



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 175

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?
    invalid_properties.push('invalid value for "rollout_pct", rollout_pct cannot be nil.')
  end

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

  if @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



315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 315

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



207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb', line 207

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', ["rollout"])
  return false unless type_validator.valid?(@type)
  return false if @rollout_pct.nil?
  return false if @rollout_pct > 10000
  return false if @rollout_pct < 0
  true
end