Class: Shipeasy::Admin::Generated::UpdateExperimentRequest

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

Overview

Body for PATCH /api/admin/experiments/{id}. Partial — only supplied fields change. allocation_pct, groups, salt, universe, params are immutable while the experiment is running (stop first).

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



174
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 174

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Shipeasy::Admin::Generated::UpdateExperimentRequest` 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::UpdateExperimentRequest`. 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?(:'name')
    self.name = attributes[:'name']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#allocation_pctObject

Basis-points allocation (0–10000). Use allocation_percent (0–100) for percent. Immutable while the experiment is running.



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

def allocation_pct
  @allocation_pct
end

#allocation_percentObject

Allocation as a percentage (0–100). Friendlier alias for allocation_pct; converted to basis points server-side. Wins over allocation_pct if both are supplied. Immutable while running.



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

def allocation_percent
  @allocation_percent
end

#audienceObject

Returns the value of attribute audience.



30
31
32
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 30

def audience
  @audience
end

#bucket_byObject

User-attribute name used as the bucketing key — e.g. user_id (default), session_id, device_id, or a custom attribute like company_id to keep a whole org on one variant. Defaults to user_id when omitted.



33
34
35
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 33

def bucket_by
  @bucket_by
end

#descriptionObject

Returns the value of attribute description.



22
23
24
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 22

def description
  @description
end

#folderObject

Optional folder name grouping items in the dashboard. Alphanumeric, _ or - (no /). Part of the SDK lookup key (<folder>/<name>).



36
37
38
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 36

def folder
  @folder
end

#goal_metricObject

Replaces the goal metric — DSL query or event (+aggregation/value) the server compiles (event auto-upserted).



67
68
69
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 67

def goal_metric
  @goal_metric
end

#groupsObject

Replacement groups. Weights must sum to 10000. Immutable while running.



56
57
58
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 56

def groups
  @groups
end

#guardrail_metricsObject

Replaces the guardrail set wholesale (event auto-upserted per entry).



70
71
72
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 70

def guardrail_metrics
  @guardrail_metrics
end

#hypothesisObject

Returns the value of attribute hypothesis.



24
25
26
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 24

def hypothesis
  @hypothesis
end

#min_runtime_daysObject

Returns the value of attribute min_runtime_days.



60
61
62
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 60

def min_runtime_days
  @min_runtime_days
end

#min_sample_sizeObject

Returns the value of attribute min_sample_size.



62
63
64
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 62

def min_sample_size
  @min_sample_size
end

#nameObject

Stable experiment key. Single segment or folder.name (a-z, 0-9, _/-; max 128 chars). Used by SDKs as Shipeasy.getExperiment(user, '<name>'). Immutable after create.



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

def name
  @name
end

#owner_emailObject

Returns the value of attribute owner_email.



28
29
30
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 28

def owner_email
  @owner_email
end

#paramsObject

Map of param-name → scalar type. Defines the shape of groups[].params. Example: { headline: 'string', show_cta: 'bool' }.



53
54
55
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 53

def params
  @params
end

#saltObject

Hash salt. Immutable while running.



47
48
49
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 47

def salt
  @salt
end

#sequential_testingObject

Returns the value of attribute sequential_testing.



64
65
66
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 64

def sequential_testing
  @sequential_testing
end

#significance_thresholdObject

Returns the value of attribute significance_threshold.



58
59
60
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 58

def significance_threshold
  @significance_threshold
end

#tagObject

Returns the value of attribute tag.



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

def tag
  @tag
end

#targeting_gateObject

Returns the value of attribute targeting_gate.



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

def targeting_gate
  @targeting_gate
end

#universeObject

New universe name. Immutable while running. Returns 422 if the universe doesn't exist.



50
51
52
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 50

def universe
  @universe
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



122
123
124
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 122

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



127
128
129
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 127

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 95

def self.attribute_map
  {
    :'name' => :'name',
    :'description' => :'description',
    :'hypothesis' => :'hypothesis',
    :'tag' => :'tag',
    :'owner_email' => :'owner_email',
    :'audience' => :'audience',
    :'bucket_by' => :'bucket_by',
    :'folder' => :'folder',
    :'targeting_gate' => :'targeting_gate',
    :'allocation_pct' => :'allocation_pct',
    :'allocation_percent' => :'allocation_percent',
    :'salt' => :'salt',
    :'universe' => :'universe',
    :'params' => :'params',
    :'groups' => :'groups',
    :'significance_threshold' => :'significance_threshold',
    :'min_runtime_days' => :'min_runtime_days',
    :'min_sample_size' => :'min_sample_size',
    :'sequential_testing' => :'sequential_testing',
    :'goal_metric' => :'goal_metric',
    :'guardrail_metrics' => :'guardrail_metrics'
  }
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



709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 709

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



159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 159

def self.openapi_nullable
  Set.new([
    :'description',
    :'hypothesis',
    :'tag',
    :'owner_email',
    :'audience',
    :'bucket_by',
    :'folder',
    :'targeting_gate',
  ])
end

.openapi_typesObject

Attribute type mapping.



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/shipeasy_admin/models/update_experiment_request.rb', line 132

def self.openapi_types
  {
    :'name' => :'String',
    :'description' => :'String',
    :'hypothesis' => :'String',
    :'tag' => :'String',
    :'owner_email' => :'String',
    :'audience' => :'String',
    :'bucket_by' => :'String',
    :'folder' => :'String',
    :'targeting_gate' => :'String',
    :'allocation_pct' => :'Integer',
    :'allocation_percent' => :'Float',
    :'salt' => :'String',
    :'universe' => :'String',
    :'params' => :'Hash<String, String>',
    :'groups' => :'Array<ListExperimentsResponseDataInnerGroupsInner>',
    :'significance_threshold' => :'Float',
    :'min_runtime_days' => :'Integer',
    :'min_sample_size' => :'Integer',
    :'sequential_testing' => :'Boolean',
    :'goal_metric' => :'ExperimentInlineMetric',
    :'guardrail_metrics' => :'Array<ExperimentInlineMetric>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 668

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      name == o.name &&
      description == o.description &&
      hypothesis == o.hypothesis &&
      tag == o.tag &&
      owner_email == o.owner_email &&
      audience == o.audience &&
      bucket_by == o.bucket_by &&
      folder == o.folder &&
      targeting_gate == o.targeting_gate &&
      allocation_pct == o.allocation_pct &&
      allocation_percent == o.allocation_percent &&
      salt == o.salt &&
      universe == o.universe &&
      params == o.params &&
      groups == o.groups &&
      significance_threshold == o.significance_threshold &&
      min_runtime_days == o.min_runtime_days &&
      min_sample_size == o.min_sample_size &&
      sequential_testing == o.sequential_testing &&
      goal_metric == o.goal_metric &&
      guardrail_metrics == o.guardrail_metrics
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


696
697
698
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 696

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



702
703
704
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 702

def hash
  [name, description, hypothesis, tag, owner_email, audience, bucket_by, folder, targeting_gate, allocation_pct, allocation_percent, salt, universe, params, groups, significance_threshold, min_runtime_days, min_sample_size, sequential_testing, goal_metric, guardrail_metrics].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 281

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@name.nil? && @name.to_s.length > 128
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 128.')
  end

  pattern = Regexp.new(/^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)?$/)
  if !@name.nil? && @name !~ pattern
    invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
  end

  if !@description.nil? && @description.to_s.length > 2000
    invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 2000.')
  end

  if !@hypothesis.nil? && @hypothesis.to_s.length > 4000
    invalid_properties.push('invalid value for "hypothesis", the character length must be smaller than or equal to 4000.')
  end

  if !@tag.nil? && @tag.to_s.length > 64
    invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 64.')
  end

  if !@owner_email.nil? && @owner_email.to_s.length > 254
    invalid_properties.push('invalid value for "owner_email", the character length must be smaller than or equal to 254.')
  end

  if !@audience.nil? && @audience.to_s.length > 256
    invalid_properties.push('invalid value for "audience", the character length must be smaller than or equal to 256.')
  end

  if !@bucket_by.nil? && @bucket_by.to_s.length > 128
    invalid_properties.push('invalid value for "bucket_by", the character length must be smaller than or equal to 128.')
  end

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

  pattern = Regexp.new(/^[a-zA-Z_][a-zA-Z0-9_]*$/)
  if !@bucket_by.nil? && @bucket_by !~ pattern
    invalid_properties.push("invalid value for \"bucket_by\", must conform to the pattern #{pattern}.")
  end

  if !@folder.nil? && @folder.to_s.length > 256
    invalid_properties.push('invalid value for "folder", the character length must be smaller than or equal to 256.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if !@folder.nil? && @folder !~ pattern
    invalid_properties.push("invalid value for \"folder\", must conform to the pattern #{pattern}.")
  end

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

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

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

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

  if !@salt.nil? && @salt.to_s.length > 64
    invalid_properties.push('invalid value for "salt", the character length must be smaller than or equal to 64.')
  end

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

  if !@groups.nil? && @groups.length < 2
    invalid_properties.push('invalid value for "groups", number of items must be greater than or equal to 2.')
  end

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

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

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

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

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

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

  if !@guardrail_metrics.nil? && @guardrail_metrics.length > 10
    invalid_properties.push('invalid value for "guardrail_metrics", number of items must be less than or equal to 10.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 731

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



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/shipeasy_admin/models/update_experiment_request.rb', line 396

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@name.nil? && @name.to_s.length > 128
  return false if !@name.nil? && @name !~ Regexp.new(/^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)?$/)
  return false if !@description.nil? && @description.to_s.length > 2000
  return false if !@hypothesis.nil? && @hypothesis.to_s.length > 4000
  return false if !@tag.nil? && @tag.to_s.length > 64
  return false if !@owner_email.nil? && @owner_email.to_s.length > 254
  return false if !@audience.nil? && @audience.to_s.length > 256
  return false if !@bucket_by.nil? && @bucket_by.to_s.length > 128
  return false if !@bucket_by.nil? && @bucket_by.to_s.length < 1
  return false if !@bucket_by.nil? && @bucket_by !~ Regexp.new(/^[a-zA-Z_][a-zA-Z0-9_]*$/)
  return false if !@folder.nil? && @folder.to_s.length > 256
  return false if !@folder.nil? && @folder !~ Regexp.new(/^[a-zA-Z0-9_-]+$/)
  return false if !@allocation_pct.nil? && @allocation_pct > 10000
  return false if !@allocation_pct.nil? && @allocation_pct < 0
  return false if !@allocation_percent.nil? && @allocation_percent > 100
  return false if !@allocation_percent.nil? && @allocation_percent < 0
  return false if !@salt.nil? && @salt.to_s.length > 64
  return false if !@salt.nil? && @salt.to_s.length < 1
  return false if !@groups.nil? && @groups.length < 2
  return false if !@significance_threshold.nil? && @significance_threshold > 0.5
  return false if !@significance_threshold.nil? && @significance_threshold < 0.00010
  return false if !@min_runtime_days.nil? && @min_runtime_days > 365
  return false if !@min_runtime_days.nil? && @min_runtime_days < 0
  return false if !@min_sample_size.nil? && @min_sample_size > 9007199254740991
  return false if !@min_sample_size.nil? && @min_sample_size < 1
  return false if !@guardrail_metrics.nil? && @guardrail_metrics.length > 10
  true
end