Class: Shipeasy::Admin::Generated::UniversesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/shipeasy_admin/api/universes_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UniversesApi

Returns a new instance of UniversesApi.



19
20
21
# File 'lib/shipeasy_admin/api/universes_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/shipeasy_admin/api/universes_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_universe(create_universe_request, opts = {}) ⇒ CreateUniverseResponse

Create a universe Creates a new universe. Only name is required — unit_type defaults to user_id and holdout_range defaults to null (no holdout). Returns 409 if name already exists in the project. Returns 403 if you supply holdout_range on a plan below Pro. Use cases - Default universe{ \"name\": \"primary_users\" }. Per-user randomisation, no holdout. - Reserved holdout — supply holdout_range to carve out a measurement slice excluded from all experiments. - Account-levelunit_type: 'account_id' so multi-seat accounts see one consistent variant.

Parameters:

  • create_universe_request (CreateUniverseRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



28
29
30
31
# File 'lib/shipeasy_admin/api/universes_api.rb', line 28

def create_universe(create_universe_request, opts = {})
  data, _status_code, _headers = create_universe_with_http_info(create_universe_request, opts)
  data
end

#create_universe_with_http_info(create_universe_request, opts = {}) ⇒ Array<(CreateUniverseResponse, Integer, Hash)>

Create a universe Creates a new universe. Only `name` is required — `unit_type` defaults to `user_id` and `holdout_range` defaults to `null` (no holdout). Returns `409` if `name` already exists in the project. Returns `403` if you supply `holdout_range` on a plan below Pro. Use cases - Default universe — `{ &quot;name&quot;: &quot;primary_users&quot; }`. Per-user randomisation, no holdout. - Reserved holdout — supply `holdout_range` to carve out a measurement slice excluded from all experiments. - Account-level — `unit_type: 'account_id'` so multi-seat accounts see one consistent variant.

Parameters:

  • create_universe_request (CreateUniverseRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(CreateUniverseResponse, Integer, Hash)>)

    CreateUniverseResponse data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/shipeasy_admin/api/universes_api.rb', line 39

def create_universe_with_http_info(create_universe_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UniversesApi.create_universe ...'
  end
  # verify the required parameter 'create_universe_request' is set
  if @api_client.config.client_side_validation && create_universe_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_universe_request' when calling UniversesApi.create_universe"
  end
  # resource path
  local_var_path = '/api/admin/universes'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_universe_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateUniverseResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"UniversesApi.create_universe",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UniversesApi#create_universe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_universe(id, opts = {}) ⇒ DeleteUniverseResponse

Delete a universe Soft-deletes the universe. Returns 409 if any non-archived experiment still references it — archive those experiments first. Use case: Tear down a universe after every experiment that used it has been archived.

Parameters:

  • id (String)

    Stable opaque universe id (`uni_…`) or the universe's `name`.

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

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



99
100
101
102
# File 'lib/shipeasy_admin/api/universes_api.rb', line 99

def delete_universe(id, opts = {})
  data, _status_code, _headers = delete_universe_with_http_info(id, opts)
  data
end

#delete_universe_with_http_info(id, opts = {}) ⇒ Array<(DeleteUniverseResponse, Integer, Hash)>

Delete a universe Soft-deletes the universe. Returns `409` if any non-archived experiment still references it — archive those experiments first. Use case: Tear down a universe after every experiment that used it has been archived.

Parameters:

  • id (String)

    Stable opaque universe id (`uni_…`) or the universe's `name`.

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

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(DeleteUniverseResponse, Integer, Hash)>)

    DeleteUniverseResponse data, response status code and response headers



110
111
112
113
114
115
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
# File 'lib/shipeasy_admin/api/universes_api.rb', line 110

def delete_universe_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UniversesApi.delete_universe ...'
  end
  # resource path
  local_var_path = '/api/admin/universes/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DeleteUniverseResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"UniversesApi.delete_universe",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UniversesApi#delete_universe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_universes(opts = {}) ⇒ ListUniversesResponse

List universes Returns a single page of universes ordered by created_at desc, id desc. The universes table has no updated_at, so this list is keyed on creation time. Use case: Snapshot every universe in the project — for example to audit which unit_type and holdout_range are in use before launching a new experiment.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

  • :limit (Integer)

    Page size (1–500). Defaults to 100. (default to 100)

  • :cursor (String)

    Opaque cursor returned in the previous page's `next_cursor`. Omit for the first page.

Returns:



162
163
164
165
# File 'lib/shipeasy_admin/api/universes_api.rb', line 162

def list_universes(opts = {})
  data, _status_code, _headers = list_universes_with_http_info(opts)
  data
end

#list_universes_with_http_info(opts = {}) ⇒ Array<(ListUniversesResponse, Integer, Hash)>

List universes Returns a single page of universes ordered by `created_at desc, id desc`. The universes table has no `updated_at`, so this list is keyed on creation time. Use case: Snapshot every universe in the project — for example to audit which `unit_type` and `holdout_range` are in use before launching a new experiment.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

  • :limit (Integer)

    Page size (1–500). Defaults to 100. (default to 100)

  • :cursor (String)

    Opaque cursor returned in the previous page's `next_cursor`. Omit for the first page.

Returns:

  • (Array<(ListUniversesResponse, Integer, Hash)>)

    ListUniversesResponse data, response status code and response headers



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
# File 'lib/shipeasy_admin/api/universes_api.rb', line 174

def list_universes_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UniversesApi.list_universes ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling UniversesApi.list_universes, must be smaller than or equal to 500.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling UniversesApi.list_universes, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/api/admin/universes'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListUniversesResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"UniversesApi.list_universes",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UniversesApi#list_universes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_universe(id, update_universe_request, opts = {}) ⇒ UpdateUniverseResponse

Update a universe Partial update. Only holdout_range is mutable — name and unit_type are immutable after create. Pass \"holdout_range\": null to remove an existing holdout. Use cases - Adjust holdout — change the reserved measurement slice without recreating experiments. - Remove holdout{ \"holdout_range\": null }.

Parameters:

  • id (String)

    Stable opaque universe id (`uni_…`) or the universe's `name`.

  • update_universe_request (UpdateUniverseRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



236
237
238
239
# File 'lib/shipeasy_admin/api/universes_api.rb', line 236

def update_universe(id, update_universe_request, opts = {})
  data, _status_code, _headers = update_universe_with_http_info(id, update_universe_request, opts)
  data
end

#update_universe_with_http_info(id, update_universe_request, opts = {}) ⇒ Array<(UpdateUniverseResponse, Integer, Hash)>

Update a universe Partial update. Only `holdout_range` is mutable — `name` and `unit_type` are immutable after create. Pass `&quot;holdout_range&quot;: null` to remove an existing holdout. Use cases - Adjust holdout — change the reserved measurement slice without recreating experiments. - Remove holdout — `{ &quot;holdout_range&quot;: null }`.

Parameters:

  • id (String)

    Stable opaque universe id (`uni_…`) or the universe's `name`.

  • update_universe_request (UpdateUniverseRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(UpdateUniverseResponse, Integer, Hash)>)

    UpdateUniverseResponse data, response status code and response headers



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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/shipeasy_admin/api/universes_api.rb', line 248

def update_universe_with_http_info(id, update_universe_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UniversesApi.update_universe ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling UniversesApi.update_universe"
  end
  # verify the required parameter 'update_universe_request' is set
  if @api_client.config.client_side_validation && update_universe_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_universe_request' when calling UniversesApi.update_universe"
  end
  # resource path
  local_var_path = '/api/admin/universes/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_universe_request)

  # return_type
  return_type = opts[:debug_return_type] || 'UpdateUniverseResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"UniversesApi.update_universe",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UniversesApi#update_universe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end