shipeasy-sdk 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/docs/skill/SKILL.md +6 -2
- data/lib/generators/shipeasy/install/USAGE +24 -0
- data/lib/generators/shipeasy/install/install_generator.rb +86 -0
- data/lib/generators/shipeasy/install/templates/initializer.rb.tt +41 -0
- data/lib/shipeasy/admin.rb +85 -0
- data/lib/shipeasy/sdk/version.rb +1 -1
- data/lib/shipeasy_admin/api/alert_rules_api.rb +292 -0
- data/lib/shipeasy_admin/api/attributes_api.rb +82 -0
- data/lib/shipeasy_admin/api/configs_api.rb +680 -0
- data/lib/shipeasy_admin/api/events_api.rb +438 -0
- data/lib/shipeasy_admin/api/experiments_api.rb +727 -0
- data/lib/shipeasy_admin/api/gates_api.rb +438 -0
- data/lib/shipeasy_admin/api/i18n_api.rb +507 -0
- data/lib/shipeasy_admin/api/killswitches_api.rb +526 -0
- data/lib/shipeasy_admin/api/metrics_api.rb +281 -0
- data/lib/shipeasy_admin/api/ops_api.rb +525 -0
- data/lib/shipeasy_admin/api/projects_api.rb +153 -0
- data/lib/shipeasy_admin/api/universes_api.rb +306 -0
- data/lib/shipeasy_admin/api_client.rb +441 -0
- data/lib/shipeasy_admin/api_error.rb +58 -0
- data/lib/shipeasy_admin/api_model_base.rb +88 -0
- data/lib/shipeasy_admin/configuration.rb +397 -0
- data/lib/shipeasy_admin/models/approve_event_request.rb +198 -0
- data/lib/shipeasy_admin/models/approve_event_response.rb +166 -0
- data/lib/shipeasy_admin/models/create_alert_rule_request.rb +408 -0
- data/lib/shipeasy_admin/models/create_alert_rule_response.rb +165 -0
- data/lib/shipeasy_admin/models/create_config_request.rb +280 -0
- data/lib/shipeasy_admin/models/create_config_response.rb +201 -0
- data/lib/shipeasy_admin/models/create_event_request.rb +253 -0
- data/lib/shipeasy_admin/models/create_event_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_experiment_request.rb +869 -0
- data/lib/shipeasy_admin/models/create_experiment_request_goal_metric.rb +336 -0
- data/lib/shipeasy_admin/models/create_experiment_response.rb +212 -0
- data/lib/shipeasy_admin/models/create_gate_request.rb +529 -0
- data/lib/shipeasy_admin/models/create_gate_response.rb +212 -0
- data/lib/shipeasy_admin/models/create_i18n_profile_request.rb +188 -0
- data/lib/shipeasy_admin/models/create_i18n_profile_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_killswitch_request.rb +263 -0
- data/lib/shipeasy_admin/models/create_killswitch_response.rb +201 -0
- data/lib/shipeasy_admin/models/create_metric_request.rb +415 -0
- data/lib/shipeasy_admin/models/create_metric_response.rb +193 -0
- data/lib/shipeasy_admin/models/create_ops_item_request.rb +287 -0
- data/lib/shipeasy_admin/models/create_ops_item_response.rb +177 -0
- data/lib/shipeasy_admin/models/create_universe_request.rb +289 -0
- data/lib/shipeasy_admin/models/create_universe_response.rb +212 -0
- data/lib/shipeasy_admin/models/delete_alert_rule_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_config_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_event_response.rb +189 -0
- data/lib/shipeasy_admin/models/delete_experiment_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_gate_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_killswitch_response.rb +188 -0
- data/lib/shipeasy_admin/models/delete_metric_response.rb +189 -0
- data/lib/shipeasy_admin/models/delete_universe_response.rb +188 -0
- data/lib/shipeasy_admin/models/disable_gate_response.rb +190 -0
- data/lib/shipeasy_admin/models/discard_config_draft_request.rb +190 -0
- data/lib/shipeasy_admin/models/discard_config_draft_response.rb +188 -0
- data/lib/shipeasy_admin/models/enable_gate_response.rb +190 -0
- data/lib/shipeasy_admin/models/error_response.rb +185 -0
- data/lib/shipeasy_admin/models/get_config_response.rb +351 -0
- data/lib/shipeasy_admin/models/get_current_project_response.rb +606 -0
- data/lib/shipeasy_admin/models/get_current_project_response_module_translations.rb +104 -0
- data/lib/shipeasy_admin/models/get_event_response.rb +344 -0
- data/lib/shipeasy_admin/models/get_experiment_response.rb +688 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response.rb +243 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response_experiment.rb +248 -0
- data/lib/shipeasy_admin/models/get_experiment_results_response_results_inner.rb +252 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response.rb +192 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response_experiment.rb +261 -0
- data/lib/shipeasy_admin/models/get_experiment_timeseries_response_series_inner.rb +278 -0
- data/lib/shipeasy_admin/models/get_killswitch_response.rb +270 -0
- data/lib/shipeasy_admin/models/get_metric_response.rb +378 -0
- data/lib/shipeasy_admin/models/get_ops_item_response.rb +349 -0
- data/lib/shipeasy_admin/models/link_pr_to_ops_item_request.rb +186 -0
- data/lib/shipeasy_admin/models/link_pr_to_ops_item_response.rb +166 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner.rb +478 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner_notify.rb +177 -0
- data/lib/shipeasy_admin/models/list_alert_rules_response_inner_notify_slack_channel.rb +211 -0
- data/lib/shipeasy_admin/models/list_attributes_response_inner.rb +176 -0
- data/lib/shipeasy_admin/models/list_config_activity_response_inner.rb +280 -0
- data/lib/shipeasy_admin/models/list_configs_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner.rb +351 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner_drafts_value.rb +237 -0
- data/lib/shipeasy_admin/models/list_configs_response_data_inner_envs_value.rb +237 -0
- data/lib/shipeasy_admin/models/list_events_response_inner.rb +344 -0
- data/lib/shipeasy_admin/models/list_events_response_inner_properties_inner.rb +289 -0
- data/lib/shipeasy_admin/models/list_experiments_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_experiments_response_data_inner.rb +688 -0
- data/lib/shipeasy_admin/models/list_experiments_response_data_inner_groups_inner.rb +258 -0
- data/lib/shipeasy_admin/models/list_gates_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner.rb +395 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_enabled.rb +104 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_rules_inner.rb +238 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner.rb +105 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of.rb +375 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of1.rb +331 -0
- data/lib/shipeasy_admin/models/list_gates_response_data_inner_stack_inner_one_of_ramp.rb +319 -0
- data/lib/shipeasy_admin/models/list_i18n_drafts_response_inner.rb +272 -0
- data/lib/shipeasy_admin/models/list_i18n_keys_response.rb +195 -0
- data/lib/shipeasy_admin/models/list_i18n_keys_response_keys_inner.rb +284 -0
- data/lib/shipeasy_admin/models/list_i18n_profiles_response_inner.rb +224 -0
- data/lib/shipeasy_admin/models/list_killswitches_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_killswitches_response_data_inner.rb +270 -0
- data/lib/shipeasy_admin/models/list_killswitches_response_data_inner_envs_value.rb +248 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner.rb +378 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir.rb +295 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg.rb +113 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of1.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of2.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of3.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of4.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of5.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of6.rb +188 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of7.rb +217 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of8.rb +233 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9.rb +240 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9_numerator.rb +266 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_agg_one_of9_numerator_filters_inner.rb +264 -0
- data/lib/shipeasy_admin/models/list_metrics_response_inner_query_ir_group_by.rb +228 -0
- data/lib/shipeasy_admin/models/list_ops_items_response_inner.rb +349 -0
- data/lib/shipeasy_admin/models/list_slack_channels_response.rb +195 -0
- data/lib/shipeasy_admin/models/list_slack_channels_response_channels_inner.rb +203 -0
- data/lib/shipeasy_admin/models/list_universes_response.rb +178 -0
- data/lib/shipeasy_admin/models/list_universes_response_data_inner.rb +305 -0
- data/lib/shipeasy_admin/models/notify_ops_request.rb +261 -0
- data/lib/shipeasy_admin/models/notify_ops_response.rb +193 -0
- data/lib/shipeasy_admin/models/publish_config_draft_request.rb +190 -0
- data/lib/shipeasy_admin/models/publish_config_draft_response.rb +260 -0
- data/lib/shipeasy_admin/models/publish_i18n_profile_request.rb +149 -0
- data/lib/shipeasy_admin/models/publish_i18n_profile_response.rb +404 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_request.rb +205 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_request_keys_inner.rb +192 -0
- data/lib/shipeasy_admin/models/push_i18n_keys_response.rb +261 -0
- data/lib/shipeasy_admin/models/reanalyze_experiment_response.rb +214 -0
- data/lib/shipeasy_admin/models/save_config_draft_request.rb +202 -0
- data/lib/shipeasy_admin/models/save_config_draft_response.rb +286 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_request.rb +168 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_request_metrics_inner.rb +216 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_response.rb +179 -0
- data/lib/shipeasy_admin/models/set_experiment_metrics_response_metrics_inner.rb +201 -0
- data/lib/shipeasy_admin/models/set_experiment_status_request.rb +190 -0
- data/lib/shipeasy_admin/models/set_experiment_status_response.rb +214 -0
- data/lib/shipeasy_admin/models/set_killswitch_switch_request.rb +264 -0
- data/lib/shipeasy_admin/models/set_killswitch_switch_response.rb +288 -0
- data/lib/shipeasy_admin/models/unset_killswitch_switch_request.rb +237 -0
- data/lib/shipeasy_admin/models/unset_killswitch_switch_response.rb +289 -0
- data/lib/shipeasy_admin/models/update_alert_rule_request.rb +306 -0
- data/lib/shipeasy_admin/models/update_alert_rule_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_config_request.rb +198 -0
- data/lib/shipeasy_admin/models/update_config_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_event_request.rb +198 -0
- data/lib/shipeasy_admin/models/update_event_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_experiment_request.rb +746 -0
- data/lib/shipeasy_admin/models/update_experiment_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_gate_request.rb +403 -0
- data/lib/shipeasy_admin/models/update_gate_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_i18n_key_request.rb +176 -0
- data/lib/shipeasy_admin/models/update_i18n_key_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_killswitch_request.rb +224 -0
- data/lib/shipeasy_admin/models/update_killswitch_response.rb +165 -0
- data/lib/shipeasy_admin/models/update_ops_item_request.rb +205 -0
- data/lib/shipeasy_admin/models/update_ops_item_response.rb +166 -0
- data/lib/shipeasy_admin/models/update_universe_request.rb +213 -0
- data/lib/shipeasy_admin/models/update_universe_response.rb +165 -0
- data/lib/shipeasy_admin/models/upsert_project_request.rb +222 -0
- data/lib/shipeasy_admin/models/upsert_project_response.rb +260 -0
- data/lib/shipeasy_admin/version.rb +15 -0
- data/lib/shipeasy_admin.rb +196 -0
- metadata +230 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 434e056f9f0849c73316e812f9ff8918ad838d9161283db0b3a8c9c7450b1077
|
|
4
|
+
data.tar.gz: beb6a893abc08ec7463a64fb2ec22f7df014f4da147b824a5f7b8d70ed3f34a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17339d55c4ed50599d3cc2cfa04f2f5a53e57a5478fb626bbf999ac6297da3a35a47e9a139150b4cfcce209c6e29f1b033180c9f5cc64923f106f5c1379adff8
|
|
7
|
+
data.tar.gz: 57fb7a408683111fd2f0aee2b389c97f5de038b22b2b6bbf0ff757c193220740a766951a7cda8baa59c58fc83bc26ea7e1103a07944e9206555a22970d071b19
|
data/README.md
CHANGED
|
@@ -84,6 +84,7 @@ Constructing `Shipeasy::Client.new(user)` before `Shipeasy.configure` raises
|
|
|
84
84
|
| [Testing](https://github.com/shipeasy-ai/sdk-ruby/blob/main/docs/pages/testing.md) | `configure_for_testing` / `configure_for_offline`, overrides. |
|
|
85
85
|
| [OpenFeature](https://github.com/shipeasy-ai/sdk-ruby/blob/main/docs/pages/openfeature.md) | `Shipeasy::OpenFeature::Provider` (OpenFeature server provider). |
|
|
86
86
|
| [Advanced](https://github.com/shipeasy-ai/sdk-ruby/blob/main/docs/pages/advanced.md) | Anon-id middleware, private attributes, sticky bucketing, SSR. |
|
|
87
|
+
| [Admin API client](https://github.com/shipeasy-ai/sdk-ruby/blob/main/docs/pages/admin-api.md) | Optional `Shipeasy::Admin::Client` for administering resources (generated from the Open… |
|
|
87
88
|
|
|
88
89
|
Copy-paste snippets live under [`docs/snippets/`](https://github.com/shipeasy-ai/sdk-ruby/blob/main/docs/snippets)
|
|
89
90
|
(release · metrics · i18n · ops); an installable agent skill is at
|
data/docs/skill/SKILL.md
CHANGED
|
@@ -37,8 +37,12 @@ Omit `c.attributes` if your user object is already the attribute hash. For a
|
|
|
37
37
|
long-running server set `c.poll = true` to keep the blob fresh in the background;
|
|
38
38
|
the default (one-shot fetch, no thread) is serverless-friendly.
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
(
|
|
40
|
+
**Rails:** don't write the initializer by hand — run the generator:
|
|
41
|
+
`bin/rails generate shipeasy:install` (add `--i18n` to also inject
|
|
42
|
+
`<%= i18n_head_tags %>` into the app layout, `--no-poll` for serverless).
|
|
43
|
+
|
|
44
|
+
→ More: `pages/installation.md` (per-framework setup + generator),
|
|
45
|
+
`pages/configuration.md` (every option).
|
|
42
46
|
|
|
43
47
|
## Evaluate (bound `Client.new(user)` — NO user arg)
|
|
44
48
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Install Shipeasy into a Rails app. Creates the config/initializers/shipeasy.rb
|
|
3
|
+
initializer that calls `Shipeasy.configure` once at boot. With --i18n it also
|
|
4
|
+
sets the public client key and injects `<%= i18n_head_tags %>` into your
|
|
5
|
+
application layout's <head>.
|
|
6
|
+
|
|
7
|
+
The gem's Railties already auto-mount the anon-id Rack middleware and the i18n
|
|
8
|
+
view helpers, so this generator only creates what your app must own — the
|
|
9
|
+
initializer, the (optional) layout tag, and a reminder to set your keys.
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
rails generate shipeasy:install
|
|
13
|
+
|
|
14
|
+
Creates:
|
|
15
|
+
config/initializers/shipeasy.rb (server key + background poll)
|
|
16
|
+
|
|
17
|
+
rails generate shipeasy:install --i18n
|
|
18
|
+
|
|
19
|
+
Also sets the public client key in the initializer and injects
|
|
20
|
+
<%= i18n_head_tags %> into app/views/layouts/application.html.erb
|
|
21
|
+
|
|
22
|
+
rails generate shipeasy:install --no-poll
|
|
23
|
+
|
|
24
|
+
One-shot fetch instead of the background poll (serverless / Lambda).
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators/base"
|
|
4
|
+
|
|
5
|
+
module Shipeasy
|
|
6
|
+
module Generators
|
|
7
|
+
# `rails generate shipeasy:install`
|
|
8
|
+
#
|
|
9
|
+
# Scaffolds Shipeasy into a Rails app the Rails way:
|
|
10
|
+
#
|
|
11
|
+
# - writes config/initializers/shipeasy.rb (the single Shipeasy.configure call)
|
|
12
|
+
# - with --i18n, sets the public client key in that initializer AND injects
|
|
13
|
+
# `<%= i18n_head_tags %>` into the application layout's <head>
|
|
14
|
+
# - prints the keys / credentials next steps
|
|
15
|
+
#
|
|
16
|
+
# The gem's Railties already auto-mount the anon-id Rack middleware and the
|
|
17
|
+
# i18n view helpers, so this generator never touches middleware wiring — it
|
|
18
|
+
# only creates the things an app must own: the initializer, the layout tag,
|
|
19
|
+
# and your keys.
|
|
20
|
+
class InstallGenerator < Rails::Generators::Base
|
|
21
|
+
source_root File.expand_path("templates", __dir__)
|
|
22
|
+
|
|
23
|
+
desc "Create config/initializers/shipeasy.rb (and, with --i18n, wire the i18n view helpers)."
|
|
24
|
+
|
|
25
|
+
class_option :i18n, type: :boolean, default: false,
|
|
26
|
+
desc: "Also enable i18n: set the public client key and inject i18n_head_tags into the app layout"
|
|
27
|
+
class_option :poll, type: :boolean, default: true,
|
|
28
|
+
desc: "Use the background poll (long-running server). Pass --no-poll for a serverless one-shot fetch"
|
|
29
|
+
|
|
30
|
+
APP_LAYOUT = "app/views/layouts/application.html.erb"
|
|
31
|
+
|
|
32
|
+
def create_initializer
|
|
33
|
+
template "initializer.rb.tt", "config/initializers/shipeasy.rb"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def inject_layout_helpers
|
|
37
|
+
return unless options[:i18n]
|
|
38
|
+
|
|
39
|
+
unless layout_exists?
|
|
40
|
+
say_status :skip, "#{APP_LAYOUT} not found — add <%= i18n_head_tags %> to your <head> by hand", :yellow
|
|
41
|
+
return
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if layout_already_wired?
|
|
45
|
+
say_status :identical, "#{APP_LAYOUT} already has i18n_head_tags", :blue
|
|
46
|
+
return
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Insert just before the closing </head>, picking up its indentation.
|
|
50
|
+
inject_into_file APP_LAYOUT, "<%= i18n_head_tags %>\n ", before: "</head>"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def print_next_steps
|
|
54
|
+
say ""
|
|
55
|
+
say " Shipeasy installed → config/initializers/shipeasy.rb", :green
|
|
56
|
+
say ""
|
|
57
|
+
say " Next steps:"
|
|
58
|
+
say " 1. Mint your keys: https://app.shipeasy.ai → Settings → SDK keys"
|
|
59
|
+
say " 2. Provide them (pick one):"
|
|
60
|
+
say " • ENV — set SHIPEASY_SERVER_KEY#{options[:i18n] ? " and SHIPEASY_CLIENT_KEY" : ""}"
|
|
61
|
+
say " • Rails credentials — bin/rails credentials:edit, then read"
|
|
62
|
+
say " them from Rails.application.credentials in the initializer"
|
|
63
|
+
if options[:i18n]
|
|
64
|
+
say " 3. i18n_head_tags is wired into your layout — run the Shipeasy"
|
|
65
|
+
say " i18n install to create your en:prod profile, then translate."
|
|
66
|
+
end
|
|
67
|
+
say ""
|
|
68
|
+
say " Read a flag anywhere per request:"
|
|
69
|
+
say " Shipeasy::Client.new(current_user).get_flag(\"new_checkout\")"
|
|
70
|
+
say ""
|
|
71
|
+
say " Docs: https://docs.shipeasy.ai", :cyan
|
|
72
|
+
say ""
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
|
|
77
|
+
def layout_exists?
|
|
78
|
+
File.exist?(File.join(destination_root, APP_LAYOUT))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def layout_already_wired?
|
|
82
|
+
File.read(File.join(destination_root, APP_LAYOUT)).include?("i18n_head_tags")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Shipeasy — feature flags, dynamic configs, kill switches, A/B experiments,
|
|
4
|
+
# metrics and (optional) i18n. Generated by `rails generate shipeasy:install`.
|
|
5
|
+
#
|
|
6
|
+
# Configure the SDK ONCE here at boot, then construct a cheap, user-bound
|
|
7
|
+
# `Shipeasy::Client.new(current_user)` per request — every read takes no user
|
|
8
|
+
# argument because the user is bound at construction:
|
|
9
|
+
#
|
|
10
|
+
# flags = Shipeasy::Client.new(current_user)
|
|
11
|
+
# flags.get_flag("new_checkout") # NO user arg — bound at construction
|
|
12
|
+
#
|
|
13
|
+
# Docs: https://docs.shipeasy.ai
|
|
14
|
+
Shipeasy.configure do |c|
|
|
15
|
+
# Required — your Shipeasy SERVER key. A server-side secret; never embed it in
|
|
16
|
+
# the browser. Read it from the environment, or from Rails credentials:
|
|
17
|
+
# c.api_key = Rails.application.credentials.dig(:shipeasy, :server_key)
|
|
18
|
+
c.api_key = ENV.fetch("SHIPEASY_SERVER_KEY", nil)
|
|
19
|
+
|
|
20
|
+
<% if options[:poll] -%>
|
|
21
|
+
# Long-running server (Puma): keep flags fresh with the background poll
|
|
22
|
+
# (initial fetch + periodic refresh). Set to false for serverless /
|
|
23
|
+
# short-lived processes — they get a one-shot fetch and no background thread.
|
|
24
|
+
c.poll = true
|
|
25
|
+
<% else -%>
|
|
26
|
+
# Serverless / short-lived process: one-shot fetch, no background thread.
|
|
27
|
+
c.poll = false
|
|
28
|
+
<% end -%>
|
|
29
|
+
|
|
30
|
+
# Optional — map YOUR user object to the Shipeasy attribute hash that
|
|
31
|
+
# targeting evaluates against. Runs once, in the Shipeasy::Client constructor.
|
|
32
|
+
# Delete this line to pass the object through unchanged (identity default).
|
|
33
|
+
c.attributes = ->(user) { { "user_id" => user.id } }
|
|
34
|
+
<% if options[:i18n] -%>
|
|
35
|
+
|
|
36
|
+
# i18n view helpers (i18n_head_tags / i18n_t) — the PUBLIC client key. Safe to
|
|
37
|
+
# expose to the browser via the loader tag these helpers emit.
|
|
38
|
+
c.public_key = ENV.fetch("SHIPEASY_CLIENT_KEY", nil)
|
|
39
|
+
c.profile = "en:prod"
|
|
40
|
+
<% end -%>
|
|
41
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Optional Admin API client for the Shipeasy Ruby SDK.
|
|
4
|
+
#
|
|
5
|
+
# This subpackage is OFF by default: the main `shipeasy-sdk` entrypoint never
|
|
6
|
+
# requires it, and its HTTP dependency (`faraday`) is an optional development
|
|
7
|
+
# dependency — so `require "shipeasy-sdk"` never pulls it in. Require it
|
|
8
|
+
# explicitly when you want to *administer* resources (create gates, start
|
|
9
|
+
# experiments, …) from server code:
|
|
10
|
+
#
|
|
11
|
+
# require "faraday"
|
|
12
|
+
# require "shipeasy/admin"
|
|
13
|
+
#
|
|
14
|
+
# admin = Shipeasy::Admin::Client.new(
|
|
15
|
+
# api_key: ENV.fetch("SHIPEASY_ADMIN_KEY"),
|
|
16
|
+
# project_id: ENV.fetch("SHIPEASY_PROJECT_ID"),
|
|
17
|
+
# )
|
|
18
|
+
# admin.gates.list_gates
|
|
19
|
+
#
|
|
20
|
+
# Everything under `Shipeasy::Admin::Generated` (lib/shipeasy_admin*) is produced
|
|
21
|
+
# by scripts/gen_admin.sh from the OpenAPI spec and must not be edited by hand.
|
|
22
|
+
# `Client` is a thin auth/scoping wrapper; it does NOT add name->id resolution or
|
|
23
|
+
# percent->basis-point conversion (that facade lives in the Shipeasy CLI/MCP). The
|
|
24
|
+
# surface here is the raw, 1:1-with-the-spec REST API.
|
|
25
|
+
|
|
26
|
+
# Define the namespace BEFORE loading the generated client: its files use the
|
|
27
|
+
# compact `module Shipeasy::Admin::Generated` form, which requires Shipeasy::Admin
|
|
28
|
+
# to already exist (and `require "shipeasy/admin"` may run without the main SDK).
|
|
29
|
+
module Shipeasy
|
|
30
|
+
module Admin
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
require "shipeasy_admin" # the generated client (loads faraday transitively)
|
|
35
|
+
|
|
36
|
+
module Shipeasy
|
|
37
|
+
module Admin
|
|
38
|
+
# Programmatic client for the Shipeasy Admin REST API. Each resource group is
|
|
39
|
+
# a lazily-constructed, memoized reader whose methods map 1:1 to the OpenAPI
|
|
40
|
+
# operations: #gates, #configs, #killswitches, #experiments, #universes,
|
|
41
|
+
# #metrics, #events, #alert_rules, #attributes, #projects, #ops, #i18n.
|
|
42
|
+
class Client
|
|
43
|
+
# Friendly reader name => generated Api class.
|
|
44
|
+
APIS = {
|
|
45
|
+
gates: Generated::GatesApi,
|
|
46
|
+
configs: Generated::ConfigsApi,
|
|
47
|
+
killswitches: Generated::KillswitchesApi,
|
|
48
|
+
experiments: Generated::ExperimentsApi,
|
|
49
|
+
universes: Generated::UniversesApi,
|
|
50
|
+
metrics: Generated::MetricsApi,
|
|
51
|
+
events: Generated::EventsApi,
|
|
52
|
+
alert_rules: Generated::AlertRulesApi,
|
|
53
|
+
attributes: Generated::AttributesApi,
|
|
54
|
+
projects: Generated::ProjectsApi,
|
|
55
|
+
ops: Generated::OpsApi,
|
|
56
|
+
i18n: Generated::I18nApi,
|
|
57
|
+
}.freeze
|
|
58
|
+
|
|
59
|
+
# @param api_key [String] admin SDK key, sent as `Authorization: Bearer <api_key>`.
|
|
60
|
+
# @param project_id [String, nil] optional project id sent as the `X-Project-Id`
|
|
61
|
+
# header on every request. Operations also accept an explicit `x_project_id:`
|
|
62
|
+
# argument to override per call.
|
|
63
|
+
# @param base_url [String] API base URL. Defaults to https://shipeasy.ai
|
|
64
|
+
# (the spec's production server); use http://localhost:3000 for local dev.
|
|
65
|
+
def initialize(api_key:, project_id: nil, base_url: "https://shipeasy.ai")
|
|
66
|
+
config = Generated::Configuration.new
|
|
67
|
+
config.access_token = api_key
|
|
68
|
+
scheme, _, host = base_url.rpartition("://")
|
|
69
|
+
config.scheme = scheme unless scheme.empty?
|
|
70
|
+
config.host = host.empty? ? base_url : host
|
|
71
|
+
|
|
72
|
+
@api_client = Generated::ApiClient.new(config)
|
|
73
|
+
@api_client.default_headers["X-Project-Id"] = project_id if project_id
|
|
74
|
+
@apis = {}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# The underlying generated ApiClient (advanced/escape hatch).
|
|
78
|
+
attr_reader :api_client
|
|
79
|
+
|
|
80
|
+
APIS.each_key do |name|
|
|
81
|
+
define_method(name) { @apis[name] ||= APIS.fetch(name).new(@api_client) }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/lib/shipeasy/sdk/version.rb
CHANGED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Shipeasy Admin API
|
|
3
|
+
|
|
4
|
+
#REST API for managing feature gates, experiments, configs, universes, and killswitches in a Shipeasy project. Authenticate with an admin SDK key (`Authorization: Bearer sdk_admin_…`) and scope every request to a project via the `X-Project-Id` header. Mint admin keys via `POST /api/admin/keys` with `type: \"admin\"`. Keys expire after 90 days; rotate with the `revoke` action.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.23.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module Shipeasy::Admin::Generated
|
|
16
|
+
class AlertRulesApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Create an alert rule
|
|
23
|
+
# Creates a metric-threshold alert rule. `name`, `metricId`, `comparator`, and `threshold` are required; `windowHours` defaults to `24`, `severity` to `warn`, and `enabled` to `true`. Returns `404` if `metricId` does not resolve, and `400` for a metric with no scalar form over a window (e.g. retention metrics) — the cron can't evaluate those. **Use cases** - **Threshold alert** — warn when an error/latency metric crosses a value over a rolling window. - **Routed alert** — set `notify` to page a specific Slack channel or on-call email instead of the project default.
|
|
24
|
+
# @param create_alert_rule_request [CreateAlertRuleRequest]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @option opts [String] :x_project_id 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).
|
|
27
|
+
# @return [CreateAlertRuleResponse]
|
|
28
|
+
def create_alert_rule(create_alert_rule_request, opts = {})
|
|
29
|
+
data, _status_code, _headers = create_alert_rule_with_http_info(create_alert_rule_request, opts)
|
|
30
|
+
data
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Create an alert rule
|
|
34
|
+
# Creates a metric-threshold alert rule. `name`, `metricId`, `comparator`, and `threshold` are required; `windowHours` defaults to `24`, `severity` to `warn`, and `enabled` to `true`. Returns `404` if `metricId` does not resolve, and `400` for a metric with no scalar form over a window (e.g. retention metrics) — the cron can't evaluate those. **Use cases** - **Threshold alert** — warn when an error/latency metric crosses a value over a rolling window. - **Routed alert** — set `notify` to page a specific Slack channel or on-call email instead of the project default.
|
|
35
|
+
# @param create_alert_rule_request [CreateAlertRuleRequest]
|
|
36
|
+
# @param [Hash] opts the optional parameters
|
|
37
|
+
# @option opts [String] :x_project_id 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).
|
|
38
|
+
# @return [Array<(CreateAlertRuleResponse, Integer, Hash)>] CreateAlertRuleResponse data, response status code and response headers
|
|
39
|
+
def create_alert_rule_with_http_info(create_alert_rule_request, opts = {})
|
|
40
|
+
if @api_client.config.debugging
|
|
41
|
+
@api_client.config.logger.debug 'Calling API: AlertRulesApi.create_alert_rule ...'
|
|
42
|
+
end
|
|
43
|
+
# verify the required parameter 'create_alert_rule_request' is set
|
|
44
|
+
if @api_client.config.client_side_validation && create_alert_rule_request.nil?
|
|
45
|
+
fail ArgumentError, "Missing the required parameter 'create_alert_rule_request' when calling AlertRulesApi.create_alert_rule"
|
|
46
|
+
end
|
|
47
|
+
# resource path
|
|
48
|
+
local_var_path = '/api/admin/alert-rules'
|
|
49
|
+
|
|
50
|
+
# query parameters
|
|
51
|
+
query_params = opts[:query_params] || {}
|
|
52
|
+
|
|
53
|
+
# header parameters
|
|
54
|
+
header_params = opts[:header_params] || {}
|
|
55
|
+
# HTTP header 'Accept' (if needed)
|
|
56
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
57
|
+
# HTTP header 'Content-Type'
|
|
58
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
59
|
+
if !content_type.nil?
|
|
60
|
+
header_params['Content-Type'] = content_type
|
|
61
|
+
end
|
|
62
|
+
header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?
|
|
63
|
+
|
|
64
|
+
# form parameters
|
|
65
|
+
form_params = opts[:form_params] || {}
|
|
66
|
+
|
|
67
|
+
# http body (model)
|
|
68
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_alert_rule_request)
|
|
69
|
+
|
|
70
|
+
# return_type
|
|
71
|
+
return_type = opts[:debug_return_type] || 'CreateAlertRuleResponse'
|
|
72
|
+
|
|
73
|
+
# auth_names
|
|
74
|
+
auth_names = opts[:debug_auth_names] || ['bearerSdkKey']
|
|
75
|
+
|
|
76
|
+
new_options = opts.merge(
|
|
77
|
+
:operation => :"AlertRulesApi.create_alert_rule",
|
|
78
|
+
:header_params => header_params,
|
|
79
|
+
:query_params => query_params,
|
|
80
|
+
:form_params => form_params,
|
|
81
|
+
:body => post_body,
|
|
82
|
+
:auth_names => auth_names,
|
|
83
|
+
:return_type => return_type
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
87
|
+
if @api_client.config.debugging
|
|
88
|
+
@api_client.config.logger.debug "API called: AlertRulesApi#create_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
89
|
+
end
|
|
90
|
+
return data, status_code, headers
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Delete an alert rule
|
|
94
|
+
# Deletes the alert rule. The cron stops evaluating it immediately. Use this (then create a new rule) to repoint alerting at a different metric, since `metricId` is immutable. **Use case:** Remove an alert rule that is no longer needed, or as the first half of repointing a rule at a different metric.
|
|
95
|
+
# @param id [String] Stable opaque alert-rule id (`ar_…`) or the rule's `name`.
|
|
96
|
+
# @param [Hash] opts the optional parameters
|
|
97
|
+
# @option opts [String] :x_project_id 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).
|
|
98
|
+
# @return [DeleteAlertRuleResponse]
|
|
99
|
+
def delete_alert_rule(id, opts = {})
|
|
100
|
+
data, _status_code, _headers = delete_alert_rule_with_http_info(id, opts)
|
|
101
|
+
data
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Delete an alert rule
|
|
105
|
+
# Deletes the alert rule. The cron stops evaluating it immediately. Use this (then create a new rule) to repoint alerting at a different metric, since `metricId` is immutable. **Use case:** Remove an alert rule that is no longer needed, or as the first half of repointing a rule at a different metric.
|
|
106
|
+
# @param id [String] Stable opaque alert-rule id (`ar_…`) or the rule's `name`.
|
|
107
|
+
# @param [Hash] opts the optional parameters
|
|
108
|
+
# @option opts [String] :x_project_id 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).
|
|
109
|
+
# @return [Array<(DeleteAlertRuleResponse, Integer, Hash)>] DeleteAlertRuleResponse data, response status code and response headers
|
|
110
|
+
def delete_alert_rule_with_http_info(id, opts = {})
|
|
111
|
+
if @api_client.config.debugging
|
|
112
|
+
@api_client.config.logger.debug 'Calling API: AlertRulesApi.delete_alert_rule ...'
|
|
113
|
+
end
|
|
114
|
+
# resource path
|
|
115
|
+
local_var_path = '/api/admin/alert-rules/{id}'.sub('{id}', CGI.escape(id.to_s))
|
|
116
|
+
|
|
117
|
+
# query parameters
|
|
118
|
+
query_params = opts[:query_params] || {}
|
|
119
|
+
|
|
120
|
+
# header parameters
|
|
121
|
+
header_params = opts[:header_params] || {}
|
|
122
|
+
# HTTP header 'Accept' (if needed)
|
|
123
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
124
|
+
header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?
|
|
125
|
+
|
|
126
|
+
# form parameters
|
|
127
|
+
form_params = opts[:form_params] || {}
|
|
128
|
+
|
|
129
|
+
# http body (model)
|
|
130
|
+
post_body = opts[:debug_body]
|
|
131
|
+
|
|
132
|
+
# return_type
|
|
133
|
+
return_type = opts[:debug_return_type] || 'DeleteAlertRuleResponse'
|
|
134
|
+
|
|
135
|
+
# auth_names
|
|
136
|
+
auth_names = opts[:debug_auth_names] || ['bearerSdkKey']
|
|
137
|
+
|
|
138
|
+
new_options = opts.merge(
|
|
139
|
+
:operation => :"AlertRulesApi.delete_alert_rule",
|
|
140
|
+
:header_params => header_params,
|
|
141
|
+
:query_params => query_params,
|
|
142
|
+
:form_params => form_params,
|
|
143
|
+
:body => post_body,
|
|
144
|
+
:auth_names => auth_names,
|
|
145
|
+
:return_type => return_type
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
|
|
149
|
+
if @api_client.config.debugging
|
|
150
|
+
@api_client.config.logger.debug "API called: AlertRulesApi#delete_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
151
|
+
end
|
|
152
|
+
return data, status_code, headers
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# List alert rules
|
|
156
|
+
# Returns every alert rule in the project (not paginated). Each rule carries its bound `metricId`, the denormalised `metricName` (or `null` if the metric was removed), the comparator/threshold/window, severity, enabled flag, and delivery target. **Use case:** Audit which metrics have alerting configured — for example to confirm an on-call threshold is set before a launch.
|
|
157
|
+
# @param [Hash] opts the optional parameters
|
|
158
|
+
# @option opts [String] :x_project_id 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).
|
|
159
|
+
# @return [Array<ListAlertRulesResponseInner>]
|
|
160
|
+
def list_alert_rules(opts = {})
|
|
161
|
+
data, _status_code, _headers = list_alert_rules_with_http_info(opts)
|
|
162
|
+
data
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# List alert rules
|
|
166
|
+
# Returns every alert rule in the project (not paginated). Each rule carries its bound `metricId`, the denormalised `metricName` (or `null` if the metric was removed), the comparator/threshold/window, severity, enabled flag, and delivery target. **Use case:** Audit which metrics have alerting configured — for example to confirm an on-call threshold is set before a launch.
|
|
167
|
+
# @param [Hash] opts the optional parameters
|
|
168
|
+
# @option opts [String] :x_project_id 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).
|
|
169
|
+
# @return [Array<(Array<ListAlertRulesResponseInner>, Integer, Hash)>] Array<ListAlertRulesResponseInner> data, response status code and response headers
|
|
170
|
+
def list_alert_rules_with_http_info(opts = {})
|
|
171
|
+
if @api_client.config.debugging
|
|
172
|
+
@api_client.config.logger.debug 'Calling API: AlertRulesApi.list_alert_rules ...'
|
|
173
|
+
end
|
|
174
|
+
# resource path
|
|
175
|
+
local_var_path = '/api/admin/alert-rules'
|
|
176
|
+
|
|
177
|
+
# query parameters
|
|
178
|
+
query_params = opts[:query_params] || {}
|
|
179
|
+
|
|
180
|
+
# header parameters
|
|
181
|
+
header_params = opts[:header_params] || {}
|
|
182
|
+
# HTTP header 'Accept' (if needed)
|
|
183
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
184
|
+
header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?
|
|
185
|
+
|
|
186
|
+
# form parameters
|
|
187
|
+
form_params = opts[:form_params] || {}
|
|
188
|
+
|
|
189
|
+
# http body (model)
|
|
190
|
+
post_body = opts[:debug_body]
|
|
191
|
+
|
|
192
|
+
# return_type
|
|
193
|
+
return_type = opts[:debug_return_type] || 'Array<ListAlertRulesResponseInner>'
|
|
194
|
+
|
|
195
|
+
# auth_names
|
|
196
|
+
auth_names = opts[:debug_auth_names] || ['bearerSdkKey']
|
|
197
|
+
|
|
198
|
+
new_options = opts.merge(
|
|
199
|
+
:operation => :"AlertRulesApi.list_alert_rules",
|
|
200
|
+
:header_params => header_params,
|
|
201
|
+
:query_params => query_params,
|
|
202
|
+
:form_params => form_params,
|
|
203
|
+
:body => post_body,
|
|
204
|
+
:auth_names => auth_names,
|
|
205
|
+
:return_type => return_type
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
209
|
+
if @api_client.config.debugging
|
|
210
|
+
@api_client.config.logger.debug "API called: AlertRulesApi#list_alert_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
211
|
+
end
|
|
212
|
+
return data, status_code, headers
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Update an alert rule
|
|
216
|
+
# Partial update of a rule's tunable knobs. `metricId` is immutable — it is rejected by the schema (the metric also pins the aggregation), so delete + recreate to repoint a rule. Pass `\"notify\": null` to revert the rule's delivery target back to the project default. **Use cases** - **Tune sensitivity** — change `threshold`/`comparator`/`windowHours` as the metric's baseline shifts. - **Pause without losing config** — `{ \"enabled\": false }` instead of deleting the rule.
|
|
217
|
+
# @param id [String] Stable opaque alert-rule id (`ar_…`) or the rule's `name`.
|
|
218
|
+
# @param update_alert_rule_request [UpdateAlertRuleRequest]
|
|
219
|
+
# @param [Hash] opts the optional parameters
|
|
220
|
+
# @option opts [String] :x_project_id 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).
|
|
221
|
+
# @return [UpdateAlertRuleResponse]
|
|
222
|
+
def update_alert_rule(id, update_alert_rule_request, opts = {})
|
|
223
|
+
data, _status_code, _headers = update_alert_rule_with_http_info(id, update_alert_rule_request, opts)
|
|
224
|
+
data
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Update an alert rule
|
|
228
|
+
# Partial update of a rule's tunable knobs. `metricId` is immutable — it is rejected by the schema (the metric also pins the aggregation), so delete + recreate to repoint a rule. Pass `\"notify\": null` to revert the rule's delivery target back to the project default. **Use cases** - **Tune sensitivity** — change `threshold`/`comparator`/`windowHours` as the metric's baseline shifts. - **Pause without losing config** — `{ \"enabled\": false }` instead of deleting the rule.
|
|
229
|
+
# @param id [String] Stable opaque alert-rule id (`ar_…`) or the rule's `name`.
|
|
230
|
+
# @param update_alert_rule_request [UpdateAlertRuleRequest]
|
|
231
|
+
# @param [Hash] opts the optional parameters
|
|
232
|
+
# @option opts [String] :x_project_id 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).
|
|
233
|
+
# @return [Array<(UpdateAlertRuleResponse, Integer, Hash)>] UpdateAlertRuleResponse data, response status code and response headers
|
|
234
|
+
def update_alert_rule_with_http_info(id, update_alert_rule_request, opts = {})
|
|
235
|
+
if @api_client.config.debugging
|
|
236
|
+
@api_client.config.logger.debug 'Calling API: AlertRulesApi.update_alert_rule ...'
|
|
237
|
+
end
|
|
238
|
+
# verify the required parameter 'id' is set
|
|
239
|
+
if @api_client.config.client_side_validation && id.nil?
|
|
240
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling AlertRulesApi.update_alert_rule"
|
|
241
|
+
end
|
|
242
|
+
# verify the required parameter 'update_alert_rule_request' is set
|
|
243
|
+
if @api_client.config.client_side_validation && update_alert_rule_request.nil?
|
|
244
|
+
fail ArgumentError, "Missing the required parameter 'update_alert_rule_request' when calling AlertRulesApi.update_alert_rule"
|
|
245
|
+
end
|
|
246
|
+
# resource path
|
|
247
|
+
local_var_path = '/api/admin/alert-rules/{id}'.sub('{id}', CGI.escape(id.to_s))
|
|
248
|
+
|
|
249
|
+
# query parameters
|
|
250
|
+
query_params = opts[:query_params] || {}
|
|
251
|
+
|
|
252
|
+
# header parameters
|
|
253
|
+
header_params = opts[:header_params] || {}
|
|
254
|
+
# HTTP header 'Accept' (if needed)
|
|
255
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
256
|
+
# HTTP header 'Content-Type'
|
|
257
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
258
|
+
if !content_type.nil?
|
|
259
|
+
header_params['Content-Type'] = content_type
|
|
260
|
+
end
|
|
261
|
+
header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?
|
|
262
|
+
|
|
263
|
+
# form parameters
|
|
264
|
+
form_params = opts[:form_params] || {}
|
|
265
|
+
|
|
266
|
+
# http body (model)
|
|
267
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_alert_rule_request)
|
|
268
|
+
|
|
269
|
+
# return_type
|
|
270
|
+
return_type = opts[:debug_return_type] || 'UpdateAlertRuleResponse'
|
|
271
|
+
|
|
272
|
+
# auth_names
|
|
273
|
+
auth_names = opts[:debug_auth_names] || ['bearerSdkKey']
|
|
274
|
+
|
|
275
|
+
new_options = opts.merge(
|
|
276
|
+
:operation => :"AlertRulesApi.update_alert_rule",
|
|
277
|
+
:header_params => header_params,
|
|
278
|
+
:query_params => query_params,
|
|
279
|
+
:form_params => form_params,
|
|
280
|
+
:body => post_body,
|
|
281
|
+
:auth_names => auth_names,
|
|
282
|
+
:return_type => return_type
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
|
|
286
|
+
if @api_client.config.debugging
|
|
287
|
+
@api_client.config.logger.debug "API called: AlertRulesApi#update_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
288
|
+
end
|
|
289
|
+
return data, status_code, headers
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Shipeasy Admin API
|
|
3
|
+
|
|
4
|
+
#REST API for managing feature gates, experiments, configs, universes, and killswitches in a Shipeasy project. Authenticate with an admin SDK key (`Authorization: Bearer sdk_admin_…`) and scope every request to a project via the `X-Project-Id` header. Mint admin keys via `POST /api/admin/keys` with `type: \"admin\"`. Keys expire after 90 days; rotate with the `revoke` action.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.23.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module Shipeasy::Admin::Generated
|
|
16
|
+
class AttributesApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# List targeting attributes
|
|
23
|
+
# Returns every auto-inferred targeting attribute in the project — the `name` and (when known) the value `type` — for building gate/experiment targeting rules. **Use case:** Discover which user-context keys are available before authoring a targeting rule, instead of guessing attribute names.
|
|
24
|
+
# @param [Hash] opts the optional parameters
|
|
25
|
+
# @option opts [String] :x_project_id 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).
|
|
26
|
+
# @return [Array<ListAttributesResponseInner>]
|
|
27
|
+
def list_attributes(opts = {})
|
|
28
|
+
data, _status_code, _headers = list_attributes_with_http_info(opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# List targeting attributes
|
|
33
|
+
# Returns every auto-inferred targeting attribute in the project — the `name` and (when known) the value `type` — for building gate/experiment targeting rules. **Use case:** Discover which user-context keys are available before authoring a targeting rule, instead of guessing attribute names.
|
|
34
|
+
# @param [Hash] opts the optional parameters
|
|
35
|
+
# @option opts [String] :x_project_id 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).
|
|
36
|
+
# @return [Array<(Array<ListAttributesResponseInner>, Integer, Hash)>] Array<ListAttributesResponseInner> data, response status code and response headers
|
|
37
|
+
def list_attributes_with_http_info(opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: AttributesApi.list_attributes ...'
|
|
40
|
+
end
|
|
41
|
+
# resource path
|
|
42
|
+
local_var_path = '/api/admin/attributes'
|
|
43
|
+
|
|
44
|
+
# query parameters
|
|
45
|
+
query_params = opts[:query_params] || {}
|
|
46
|
+
|
|
47
|
+
# header parameters
|
|
48
|
+
header_params = opts[:header_params] || {}
|
|
49
|
+
# HTTP header 'Accept' (if needed)
|
|
50
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
51
|
+
header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?
|
|
52
|
+
|
|
53
|
+
# form parameters
|
|
54
|
+
form_params = opts[:form_params] || {}
|
|
55
|
+
|
|
56
|
+
# http body (model)
|
|
57
|
+
post_body = opts[:debug_body]
|
|
58
|
+
|
|
59
|
+
# return_type
|
|
60
|
+
return_type = opts[:debug_return_type] || 'Array<ListAttributesResponseInner>'
|
|
61
|
+
|
|
62
|
+
# auth_names
|
|
63
|
+
auth_names = opts[:debug_auth_names] || ['bearerSdkKey']
|
|
64
|
+
|
|
65
|
+
new_options = opts.merge(
|
|
66
|
+
:operation => :"AttributesApi.list_attributes",
|
|
67
|
+
:header_params => header_params,
|
|
68
|
+
:query_params => query_params,
|
|
69
|
+
:form_params => form_params,
|
|
70
|
+
:body => post_body,
|
|
71
|
+
:auth_names => auth_names,
|
|
72
|
+
:return_type => return_type
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
76
|
+
if @api_client.config.debugging
|
|
77
|
+
@api_client.config.logger.debug "API called: AttributesApi#list_attributes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
78
|
+
end
|
|
79
|
+
return data, status_code, headers
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|