smplkit 3.0.94 → 3.0.96
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/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/categories_api.rb +2 -2
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/event_types_api.rb +2 -2
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/events_api.rb +4 -4
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/resource_types_api.rb +2 -2
- data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_search_request.rb +1 -1
- data/lib/smplkit/_generated/audit/spec/api/categories_api_spec.rb +1 -1
- data/lib/smplkit/_generated/audit/spec/api/event_types_api_spec.rb +1 -1
- data/lib/smplkit/_generated/audit/spec/api/events_api_spec.rb +2 -2
- data/lib/smplkit/_generated/audit/spec/api/resource_types_api_spec.rb +1 -1
- data/lib/smplkit/account/client.rb +121 -0
- data/lib/smplkit/account/models.rb +53 -0
- data/lib/smplkit/api_support.rb +83 -0
- data/lib/smplkit/audit/client.rb +9 -10
- data/lib/smplkit/{management/audit.rb → audit/forwarders.rb} +73 -76
- data/lib/smplkit/audit/models.rb +40 -1
- data/lib/smplkit/buffers.rb +235 -0
- data/lib/smplkit/client.rb +126 -67
- data/lib/smplkit/config/client.rb +617 -182
- data/lib/smplkit/config_resolution.rb +11 -5
- data/lib/smplkit/errors.rb +8 -0
- data/lib/smplkit/flags/client.rb +472 -114
- data/lib/smplkit/flags/types.rb +6 -7
- data/lib/smplkit/{management/jobs.rb → jobs/client.rb} +148 -89
- data/lib/smplkit/logging/client.rb +647 -192
- data/lib/smplkit/logging/helpers.rb +1 -0
- data/lib/smplkit/logging/models.rb +92 -1
- data/lib/smplkit/logging/sources.rb +1 -1
- data/lib/smplkit/platform/client.rb +472 -0
- data/lib/smplkit/platform/models.rb +182 -0
- data/lib/smplkit/{management → platform}/types.rb +7 -4
- data/lib/smplkit/transport.rb +99 -0
- data/lib/smplkit.rb +18 -6
- metadata +11 -7
- data/lib/smplkit/management/buffer.rb +0 -198
- data/lib/smplkit/management/client.rb +0 -1074
- data/lib/smplkit/management/models.rb +0 -178
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1d765730dd1bb26ebf38f16627878d7d33220bc20bd005b98b12303a18e88c1
|
|
4
|
+
data.tar.gz: 1109c9cd1b02865ae3d2148a8232509b185d828ed8762c025cf82dcfc9c9c09e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '099f6f60a8acdbd5804cd32743d7f6d6e28261de9901f08a354536da0e49a8b3cec0809790106b072cd7275daa60fdd4279b979dca22590ae74d87382bed04ed'
|
|
7
|
+
data.tar.gz: '089e631caa282df42aea0344a2e38fe17795e2d773d6799e6684ee1d389d418b0d4c1714fcf398c70b8961fdd4919b11c1b7b56f26b8e7a6e1b631853ac12447'
|
|
@@ -22,7 +22,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
22
22
|
# List Categories
|
|
23
23
|
# List the distinct `category` values recorded for this account. The resource `id` is the category value itself. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Useful for populating filter dropdowns in a UI.
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
|
25
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
25
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
26
26
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
27
27
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
28
28
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
|
|
@@ -36,7 +36,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
36
36
|
# List Categories
|
|
37
37
|
# List the distinct `category` values recorded for this account. The resource `id` is the category value itself. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Useful for populating filter dropdowns in a UI.
|
|
38
38
|
# @param [Hash] opts the optional parameters
|
|
39
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
39
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
40
40
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
41
41
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
42
42
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
|
|
@@ -22,7 +22,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
22
22
|
# List Event Types
|
|
23
23
|
# List the distinct `event_type` slugs recorded for this account. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Without `filter[resource_type]`, returns one row per distinct event_type. With `filter[resource_type]`, returns the event_types recorded for that specific resource type.
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
|
25
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
25
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
26
26
|
# @option opts [String] :filter_resource_type
|
|
27
27
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
28
28
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
@@ -37,7 +37,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
37
37
|
# List Event Types
|
|
38
38
|
# List the distinct `event_type` slugs recorded for this account. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Without `filter[resource_type]`, returns one row per distinct event_type. With `filter[resource_type]`, returns the event_types recorded for that specific resource type.
|
|
39
39
|
# @param [Hash] opts the optional parameters
|
|
40
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
40
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
41
41
|
# @option opts [String] :filter_resource_type
|
|
42
42
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
43
43
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
@@ -85,7 +85,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
85
85
|
# List Events
|
|
86
86
|
# List audit events for this account. Default sort is `-occurred_at` (newest occurrence first). Sort by `occurred_at` or `created_at`, ascending or descending — keep the same `sort` value across paginated requests so the cursor stays consistent. Filters are exact-match except `filter[occurred_at]`, which uses interval notation (e.g. `[2026-01-01T00:00:00Z,2026-01-31T00:00:00Z)`), and `filter[search]`, which is a case-insensitive substring match against `resource_id` or `description`. Two filter-combination rules: - `filter[resource_id]` must be accompanied by `filter[resource_type]` (the index is keyed on the pair). - `filter[search]` must be accompanied by either `filter[occurred_at]` or `filter[resource_type]` + `filter[resource_id]` (substring matching has no index, so an unbounded substring scan is rejected). No other filter combinations are required — calling the endpoint with no query parameters returns the latest events for the account, paginated. `page[size]` defaults to 1000 and must not exceed 1000. Pass `format=CSV` or `format=JSONL` to stream a download of the full filtered result set instead of a paginated JSON:API response. The download honors every supplied filter and ignores `page[size]` and `page[after]`.
|
|
87
87
|
# @param [Hash] opts the optional parameters
|
|
88
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
88
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
89
89
|
# @option opts [String] :filter_occurred_at
|
|
90
90
|
# @option opts [String] :filter_actor_type
|
|
91
91
|
# @option opts [String] :filter_actor_id
|
|
@@ -109,7 +109,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
109
109
|
# List Events
|
|
110
110
|
# List audit events for this account. Default sort is `-occurred_at` (newest occurrence first). Sort by `occurred_at` or `created_at`, ascending or descending — keep the same `sort` value across paginated requests so the cursor stays consistent. Filters are exact-match except `filter[occurred_at]`, which uses interval notation (e.g. `[2026-01-01T00:00:00Z,2026-01-31T00:00:00Z)`), and `filter[search]`, which is a case-insensitive substring match against `resource_id` or `description`. Two filter-combination rules: - `filter[resource_id]` must be accompanied by `filter[resource_type]` (the index is keyed on the pair). - `filter[search]` must be accompanied by either `filter[occurred_at]` or `filter[resource_type]` + `filter[resource_id]` (substring matching has no index, so an unbounded substring scan is rejected). No other filter combinations are required — calling the endpoint with no query parameters returns the latest events for the account, paginated. `page[size]` defaults to 1000 and must not exceed 1000. Pass `format=CSV` or `format=JSONL` to stream a download of the full filtered result set instead of a paginated JSON:API response. The download honors every supplied filter and ignores `page[size]` and `page[after]`.
|
|
111
111
|
# @param [Hash] opts the optional parameters
|
|
112
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
112
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
113
113
|
# @option opts [String] :filter_occurred_at
|
|
114
114
|
# @option opts [String] :filter_actor_type
|
|
115
115
|
# @option opts [String] :filter_actor_id
|
|
@@ -268,7 +268,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
268
268
|
end
|
|
269
269
|
|
|
270
270
|
# Search Events
|
|
271
|
-
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted,
|
|
271
|
+
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted, results cover every environment you can access. The reserved `smplkit` value selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402. Without a JSON Logic `filter`: behaves like `GET /api/v1/events` with the same column filters. With a JSON Logic `filter`: the search is silently capped to the last 30 days by `occurred_at` (intersected with any explicit `filter[occurred_at]` the caller supplied), the column filters narrow the candidate set in SQL, and the JSON Logic expression runs in memory against each candidate row using the same `json-logic-qubit` evaluator the forwarder pipeline uses. Up to 50,000 rows are scanned per request; the response's `meta.scan` block reports the scan stats so a selective filter doesn't look like \"0 matches\" when the truth is \"ceiling reached.\"
|
|
272
272
|
# @param event_search_request [EventSearchRequest]
|
|
273
273
|
# @param [Hash] opts the optional parameters
|
|
274
274
|
# @return [EventSearchResponse]
|
|
@@ -278,7 +278,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
278
278
|
end
|
|
279
279
|
|
|
280
280
|
# Search Events
|
|
281
|
-
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted,
|
|
281
|
+
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted, results cover every environment you can access. The reserved `smplkit` value selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402. Without a JSON Logic `filter`: behaves like `GET /api/v1/events` with the same column filters. With a JSON Logic `filter`: the search is silently capped to the last 30 days by `occurred_at` (intersected with any explicit `filter[occurred_at]` the caller supplied), the column filters narrow the candidate set in SQL, and the JSON Logic expression runs in memory against each candidate row using the same `json-logic-qubit` evaluator the forwarder pipeline uses. Up to 50,000 rows are scanned per request; the response's `meta.scan` block reports the scan stats so a selective filter doesn't look like \"0 matches\" when the truth is \"ceiling reached.\"
|
|
282
282
|
# @param event_search_request [EventSearchRequest]
|
|
283
283
|
# @param [Hash] opts the optional parameters
|
|
284
284
|
# @return [Array<(EventSearchResponse, Integer, Hash)>] EventSearchResponse data, response status code and response headers
|
|
@@ -22,7 +22,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
22
22
|
# List Resource Types
|
|
23
23
|
# List the distinct `resource_type` slugs recorded for this account. The resource `id` is the slug itself. Default sort is `key` ascending; pass `sort=-key` for descending. Useful for populating filter dropdowns in a UI. Results are scoped to the selected environments (see `filter[environment]`); platform resource types appear under the reserved `smplkit` value.
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
|
25
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
25
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
26
26
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
27
27
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
28
28
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
|
|
@@ -36,7 +36,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
36
36
|
# List Resource Types
|
|
37
37
|
# List the distinct `resource_type` slugs recorded for this account. The resource `id` is the slug itself. Default sort is `key` ascending; pass `sort=-key` for descending. Useful for populating filter dropdowns in a UI. Results are scoped to the selected environments (see `filter[environment]`); platform resource types appear under the reserved `smplkit` value.
|
|
38
38
|
# @param [Hash] opts the optional parameters
|
|
39
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
39
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
40
40
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`. (default to 'key')
|
|
41
41
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error. (default to 1)
|
|
42
42
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error. (default to 1000)
|
|
@@ -19,7 +19,7 @@ module SmplkitGeneratedClient::Audit
|
|
|
19
19
|
# Optional JSON Logic expression evaluated against each row after column filters narrow the candidate set. Null, absent, or an empty object disables JSON Logic filtering. When present, the search is silently capped to the last 30 days by `occurred_at` (intersected with any explicit `filter[occurred_at]` the caller supplied).
|
|
20
20
|
attr_accessor :filter
|
|
21
21
|
|
|
22
|
-
# Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
22
|
+
# Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
23
23
|
attr_accessor :filter_environment
|
|
24
24
|
|
|
25
25
|
# Exact match on the event's `event_type` field.
|
|
@@ -36,7 +36,7 @@ describe 'CategoriesApi' do
|
|
|
36
36
|
# List Categories
|
|
37
37
|
# List the distinct `category` values recorded for this account. The resource `id` is the category value itself. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Useful for populating filter dropdowns in a UI.
|
|
38
38
|
# @param [Hash] opts the optional parameters
|
|
39
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
39
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
40
40
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`.
|
|
41
41
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error.
|
|
42
42
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error.
|
|
@@ -36,7 +36,7 @@ describe 'EventTypesApi' do
|
|
|
36
36
|
# List Event Types
|
|
37
37
|
# List the distinct `event_type` slugs recorded for this account. Default sort is `key` ascending; pass `sort=-key` for descending. Scoped to the selected environments (see `filter[environment]`). Without `filter[resource_type]`, returns one row per distinct event_type. With `filter[resource_type]`, returns the event_types recorded for that specific resource type.
|
|
38
38
|
# @param [Hash] opts the optional parameters
|
|
39
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
39
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
40
40
|
# @option opts [String] :filter_resource_type
|
|
41
41
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`.
|
|
42
42
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error.
|
|
@@ -48,7 +48,7 @@ describe 'EventsApi' do
|
|
|
48
48
|
# List Events
|
|
49
49
|
# List audit events for this account. Default sort is `-occurred_at` (newest occurrence first). Sort by `occurred_at` or `created_at`, ascending or descending — keep the same `sort` value across paginated requests so the cursor stays consistent. Filters are exact-match except `filter[occurred_at]`, which uses interval notation (e.g. `[2026-01-01T00:00:00Z,2026-01-31T00:00:00Z)`), and `filter[search]`, which is a case-insensitive substring match against `resource_id` or `description`. Two filter-combination rules: - `filter[resource_id]` must be accompanied by `filter[resource_type]` (the index is keyed on the pair). - `filter[search]` must be accompanied by either `filter[occurred_at]` or `filter[resource_type]` + `filter[resource_id]` (substring matching has no index, so an unbounded substring scan is rejected). No other filter combinations are required — calling the endpoint with no query parameters returns the latest events for the account, paginated. `page[size]` defaults to 1000 and must not exceed 1000. Pass `format=CSV` or `format=JSONL` to stream a download of the full filtered result set instead of a paginated JSON:API response. The download honors every supplied filter and ignores `page[size]` and `page[after]`.
|
|
50
50
|
# @param [Hash] opts the optional parameters
|
|
51
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
51
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
52
52
|
# @option opts [String] :filter_occurred_at
|
|
53
53
|
# @option opts [String] :filter_actor_type
|
|
54
54
|
# @option opts [String] :filter_actor_id
|
|
@@ -85,7 +85,7 @@ describe 'EventsApi' do
|
|
|
85
85
|
|
|
86
86
|
# unit tests for search_events
|
|
87
87
|
# Search Events
|
|
88
|
-
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted,
|
|
88
|
+
# Search audit events with column filters and an optional JSON Logic expression. Scoped by `filter[environment]` (a comma-separated set). When omitted, results cover every environment you can access. The reserved `smplkit` value selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402. Without a JSON Logic `filter`: behaves like `GET /api/v1/events` with the same column filters. With a JSON Logic `filter`: the search is silently capped to the last 30 days by `occurred_at` (intersected with any explicit `filter[occurred_at]` the caller supplied), the column filters narrow the candidate set in SQL, and the JSON Logic expression runs in memory against each candidate row using the same `json-logic-qubit` evaluator the forwarder pipeline uses. Up to 50,000 rows are scanned per request; the response's `meta.scan` block reports the scan stats so a selective filter doesn't look like \"0 matches\" when the truth is \"ceiling reached.\"
|
|
89
89
|
# @param event_search_request
|
|
90
90
|
# @param [Hash] opts the optional parameters
|
|
91
91
|
# @return [EventSearchResponse]
|
|
@@ -36,7 +36,7 @@ describe 'ResourceTypesApi' do
|
|
|
36
36
|
# List Resource Types
|
|
37
37
|
# List the distinct `resource_type` slugs recorded for this account. The resource `id` is the slug itself. Default sort is `key` ascending; pass `sort=-key` for descending. Useful for populating filter dropdowns in a UI. Results are scoped to the selected environments (see `filter[environment]`); platform resource types appear under the reserved `smplkit` value.
|
|
38
38
|
# @param [Hash] opts the optional parameters
|
|
39
|
-
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results
|
|
39
|
+
# @option opts [String] :filter_environment Comma-separated list of environment keys to scope results to (e.g. `production,staging`). When omitted, results cover every environment you can access. The reserved value `smplkit` selects platform change events smplkit records about your own resources; it is included by default when your plan grants change history, and requesting it explicitly without that entitlement returns 402.
|
|
40
40
|
# @option opts [String] :sort Field to sort by. Prefix with `-` for descending order. Default: `key`. Allowed values: `key`, `-key`.
|
|
41
41
|
# @option opts [Integer] :page_number 1-based page number to return. Optional; defaults to `1` when omitted. Must be `>= 1` — requests with a smaller value are rejected with a 400 error.
|
|
42
42
|
# @option opts [Integer] :page_size Number of items per page. Optional; defaults to `1000` when omitted. Must be between `1` and `1000` inclusive — requests outside that range are rejected with a 400 error.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module Smplkit
|
|
7
|
+
module Account
|
|
8
|
+
# Resolve the (app_base_url, api_key, extra_headers) for the settings client.
|
|
9
|
+
#
|
|
10
|
+
# +base_url+/+api_key+ are used directly when both are supplied (the path
|
|
11
|
+
# the top-level client takes after it has already resolved them); otherwise
|
|
12
|
+
# the management config resolver fills in whatever is missing.
|
|
13
|
+
def self.resolve_account_target(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:)
|
|
14
|
+
cfg = ConfigResolution.resolve_management_config(
|
|
15
|
+
profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme, debug: debug
|
|
16
|
+
)
|
|
17
|
+
resolved_key = api_key.nil? ? cfg.api_key : api_key
|
|
18
|
+
app_url = base_url.nil? ? ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain) : base_url
|
|
19
|
+
headers = {}
|
|
20
|
+
headers.merge!(cfg.extra_headers || {})
|
|
21
|
+
headers.merge!(extra_headers || {})
|
|
22
|
+
[app_url.sub(%r{/+\z}, ""), resolved_key, headers]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Sync account-settings get/save (+client.account.settings+).
|
|
26
|
+
#
|
|
27
|
+
# The endpoint isn't JSON:API — body is a raw JSON object — so we use an
|
|
28
|
+
# HTTP client directly rather than going through a generated client.
|
|
29
|
+
class SettingsClient
|
|
30
|
+
SETTINGS_PATH = "/api/v1/accounts/current/settings"
|
|
31
|
+
|
|
32
|
+
def initialize(app_base_url, api_key, extra_headers = nil)
|
|
33
|
+
@base_url = app_base_url
|
|
34
|
+
@headers = {
|
|
35
|
+
"Authorization" => "Bearer #{api_key}",
|
|
36
|
+
"Content-Type" => "application/json"
|
|
37
|
+
}.merge(extra_headers || {})
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get
|
|
41
|
+
resp = connection.get(SETTINGS_PATH)
|
|
42
|
+
Errors.raise_for_status(resp.status, resp.body.to_s)
|
|
43
|
+
AccountSettings.new(self, data: parse_body(resp.body))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def _save(data)
|
|
47
|
+
resp = connection.put(SETTINGS_PATH) { |req| req.body = JSON.generate(data) }
|
|
48
|
+
Errors.raise_for_status(resp.status, resp.body.to_s)
|
|
49
|
+
AccountSettings.new(self, data: parse_body(resp.body))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# A short-lived connection per call — mirrors the Python settings client
|
|
55
|
+
# opening and closing its own HTTP client each time.
|
|
56
|
+
def connection
|
|
57
|
+
Faraday.new(url: @base_url, headers: @headers, request: { timeout: 30 })
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def parse_body(body)
|
|
61
|
+
return {} if body.nil? || body.to_s.empty?
|
|
62
|
+
|
|
63
|
+
parsed = JSON.parse(body)
|
|
64
|
+
parsed.is_a?(Hash) ? parsed : {}
|
|
65
|
+
rescue JSON::ParserError
|
|
66
|
+
{}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The Smpl Account client (sync).
|
|
71
|
+
#
|
|
72
|
+
# Exposes the authenticated account's own configuration, reachable as
|
|
73
|
+
# +client.account+ (+Smplkit::Client+) or constructed directly:
|
|
74
|
+
#
|
|
75
|
+
# account = Smplkit::AccountClient.new(api_key: "sk_...")
|
|
76
|
+
# settings = account.settings.get
|
|
77
|
+
# settings.environment_order = ["production", "staging"]
|
|
78
|
+
# settings.save
|
|
79
|
+
#
|
|
80
|
+
# Sub-client: +settings+ (get/save). Pure CRUD — no +install+ required.
|
|
81
|
+
#
|
|
82
|
+
# @param api_key [String, nil] API key. When omitted, resolved from
|
|
83
|
+
# +SMPLKIT_API_KEY+ or +~/.smplkit+.
|
|
84
|
+
# @param base_url [String, nil] Full app-service base URL. Usually resolved
|
|
85
|
+
# from +base_domain+/+scheme+; supplied directly by the top-level clients
|
|
86
|
+
# which have already computed it.
|
|
87
|
+
# @param profile [String, nil] Named +~/.smplkit+ profile section.
|
|
88
|
+
# @param base_domain [String, nil] Base domain for API requests (default
|
|
89
|
+
# +"smplkit.com"+).
|
|
90
|
+
# @param scheme [String, nil] URL scheme (default +"https"+).
|
|
91
|
+
# @param debug [Boolean, nil] Enable SDK debug logging.
|
|
92
|
+
# @param extra_headers [Hash, nil] Extra headers attached to every request.
|
|
93
|
+
class AccountClient
|
|
94
|
+
attr_reader :settings
|
|
95
|
+
|
|
96
|
+
def initialize(api_key: nil, base_url: nil, profile: nil, base_domain: nil,
|
|
97
|
+
scheme: nil, debug: nil, extra_headers: nil)
|
|
98
|
+
app_url, resolved_key, headers = Account.resolve_account_target(
|
|
99
|
+
api_key: api_key, base_url: base_url, profile: profile,
|
|
100
|
+
base_domain: base_domain, scheme: scheme, debug: debug, extra_headers: extra_headers
|
|
101
|
+
)
|
|
102
|
+
@settings = SettingsClient.new(app_url, resolved_key, headers.empty? ? nil : headers)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# No-op — the settings client opens a short-lived HTTP client per call.
|
|
106
|
+
def close; end
|
|
107
|
+
|
|
108
|
+
# Construct, yield to the block, and close on exit.
|
|
109
|
+
def self.open(**kwargs)
|
|
110
|
+
client = new(**kwargs)
|
|
111
|
+
begin
|
|
112
|
+
yield client
|
|
113
|
+
ensure
|
|
114
|
+
client.close
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
AccountClient = Account::AccountClient
|
|
121
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smplkit
|
|
4
|
+
module Account
|
|
5
|
+
# Active-record account-settings model.
|
|
6
|
+
#
|
|
7
|
+
# The wire format is opaque JSON. Documented keys are exposed as typed
|
|
8
|
+
# properties; unknown keys live in +raw+. +save+ writes the full settings
|
|
9
|
+
# object back.
|
|
10
|
+
class AccountSettings
|
|
11
|
+
def initialize(client = nil, data: nil)
|
|
12
|
+
@client = client
|
|
13
|
+
@data = data ? data.dup : {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# The full settings dict. Mutations are persisted on save.
|
|
17
|
+
def raw
|
|
18
|
+
@data
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def raw=(value)
|
|
22
|
+
@data = value.dup
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Canonical ordering of STANDARD environments. Empty list if unset.
|
|
26
|
+
def environment_order
|
|
27
|
+
Array(@data["environment_order"] || [])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def environment_order=(value)
|
|
31
|
+
@data["environment_order"] = value.to_a
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def save
|
|
35
|
+
raise "AccountSettings was constructed without a client; cannot save" if @client.nil?
|
|
36
|
+
|
|
37
|
+
other = @client._save(@data)
|
|
38
|
+
_apply(other)
|
|
39
|
+
self
|
|
40
|
+
end
|
|
41
|
+
alias save! save
|
|
42
|
+
|
|
43
|
+
def to_s
|
|
44
|
+
"AccountSettings(#{@data.inspect})"
|
|
45
|
+
end
|
|
46
|
+
alias inspect to_s
|
|
47
|
+
|
|
48
|
+
def _apply(other)
|
|
49
|
+
@data = other.raw.dup
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smplkit
|
|
4
|
+
# Ruby-internal adapters bridging the generated client layer to the wrapper.
|
|
5
|
+
module ApiSupport
|
|
6
|
+
# Default page[size] the runtime asks for when walking a list endpoint to
|
|
7
|
+
# completion. The platform caps page[size] at 1000; using the same value
|
|
8
|
+
# here makes the minimum number of round-trips per exhaustive fetch.
|
|
9
|
+
RUNTIME_PAGE_SIZE = 1000
|
|
10
|
+
|
|
11
|
+
# Wraps a generated-API call and converts any +ApiError+ raised by the
|
|
12
|
+
# generated layer into the +Smplkit::Error+ hierarchy. Connection-level
|
|
13
|
+
# failures (no response from the server) become +Smplkit::ConnectionError+;
|
|
14
|
+
# status-coded failures route through +Errors.raise_for_status+ which emits
|
|
15
|
+
# +NotFoundError+ / +ConflictError+ / +ValidationError+ / +Error+ depending
|
|
16
|
+
# on the JSON:API body.
|
|
17
|
+
module ErrorMapping
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
def call
|
|
21
|
+
yield
|
|
22
|
+
rescue StandardError => e
|
|
23
|
+
raise unless generated_api_error?(e)
|
|
24
|
+
|
|
25
|
+
raise Smplkit::ConnectionError, e.message.to_s if e.code.nil? || e.code.zero?
|
|
26
|
+
|
|
27
|
+
Smplkit::Errors.raise_for_status(e.code, e.response_body.to_s)
|
|
28
|
+
# raise_for_status only returns on 2xx; if we get here the generated
|
|
29
|
+
# layer raised on a 2xx (shouldn't happen) so re-raise the original.
|
|
30
|
+
raise
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def generated_api_error?(err)
|
|
34
|
+
klass_name = err.class.name.to_s
|
|
35
|
+
klass_name.start_with?("SmplkitGeneratedClient::") && klass_name.end_with?("::ApiError")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Walk a generated paginated list endpoint to completion.
|
|
40
|
+
#
|
|
41
|
+
# The block receives a per-page +opts+ hash with +page_number+ and
|
|
42
|
+
# +page_size+ filled in, calls the generated list method through
|
|
43
|
+
# {ErrorMapping.call}, and returns the response object. Pages stop when the
|
|
44
|
+
# server returns fewer rows than requested — the platform's standard
|
|
45
|
+
# last-page signal across every offset-paginated list endpoint. Returns the
|
|
46
|
+
# concatenated +response.data+ rows.
|
|
47
|
+
module PaginatedFetch
|
|
48
|
+
module_function
|
|
49
|
+
|
|
50
|
+
def collect(page_size: RUNTIME_PAGE_SIZE)
|
|
51
|
+
rows = []
|
|
52
|
+
page_number = 1
|
|
53
|
+
loop do
|
|
54
|
+
opts = { page_number: page_number, page_size: page_size }
|
|
55
|
+
response = ErrorMapping.call { yield(opts) }
|
|
56
|
+
page = response.data || []
|
|
57
|
+
rows.concat(page)
|
|
58
|
+
break if page.length < page_size
|
|
59
|
+
|
|
60
|
+
page_number += 1
|
|
61
|
+
end
|
|
62
|
+
rows
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Deep-stringify Hash keys so resources returned by generated +to_hash+
|
|
67
|
+
# (symbol-keyed) match what the wrapper helpers expect (string-keyed).
|
|
68
|
+
module ResourceShim
|
|
69
|
+
module_function
|
|
70
|
+
|
|
71
|
+
def stringify(value)
|
|
72
|
+
Smplkit::Helpers.deep_stringify_keys(value)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Convenience: produce a string-keyed Hash from a generated model.
|
|
76
|
+
def from_model(model)
|
|
77
|
+
return {} if model.nil?
|
|
78
|
+
|
|
79
|
+
stringify(model.to_hash)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/lib/smplkit/audit/client.rb
CHANGED
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module Smplkit
|
|
4
4
|
module Audit
|
|
5
|
-
# Audit
|
|
5
|
+
# The Smpl Audit client — accessed via +client.audit+.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# SIEM forwarder CRUD lives on {Smplkit::ManagementClient} under
|
|
14
|
-
# +mgmt.audit.forwarders.*+.
|
|
7
|
+
# One client exposes the full surface — there is no runtime/management
|
|
8
|
+
# split for audit. Owns event recording and read-side queries:
|
|
9
|
+
# fire-and-forget +#events.record+, plus the audit-log +list+ / +get+ and
|
|
10
|
+
# the distinct-value listings (+resource_types+, +event_types+,
|
|
11
|
+
# +categories+) that back the Activity tab filter dropdowns, plus SIEM
|
|
12
|
+
# forwarder CRUD on +#forwarders+. ADR-047 §2.7.
|
|
15
13
|
class AuditClient
|
|
16
|
-
attr_reader :events, :resource_types, :event_types, :categories
|
|
14
|
+
attr_reader :events, :resource_types, :event_types, :categories, :forwarders
|
|
17
15
|
|
|
18
16
|
SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
|
|
19
17
|
|
|
@@ -41,6 +39,7 @@ module Smplkit
|
|
|
41
39
|
@resource_types = ResourceTypes.new(SmplkitGeneratedClient::Audit::ResourceTypesApi.new(api_client))
|
|
42
40
|
@event_types = EventTypes.new(SmplkitGeneratedClient::Audit::EventTypesApi.new(api_client))
|
|
43
41
|
@categories = Categories.new(SmplkitGeneratedClient::Audit::CategoriesApi.new(api_client))
|
|
42
|
+
@forwarders = ForwardersClient.new(SmplkitGeneratedClient::Audit::ForwardersApi.new(api_client))
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def _close
|