pgbeam 0.2.7__tar.gz → 0.2.9__tar.gz
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.
- {pgbeam-0.2.7 → pgbeam-0.2.9}/CHANGELOG.md +12 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/PKG-INFO +1 -1
- {pgbeam-0.2.7 → pgbeam-0.2.9}/pyproject.toml +1 -1
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/models.py +58 -2
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/operations.py +26 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/services.py +291 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/.gitignore +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/LICENSE +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/README.md +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/__init__.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/_client.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/_transport.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/errors.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/src/pgbeam/py.typed +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/tests/test_client.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/tests/test_errors.py +0 -0
- {pgbeam-0.2.7 → pgbeam-0.2.9}/tests/test_transport.py +0 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pgbeam/python-sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 16ed7f3: feat(proxy): content_scan_mode=block now blocks, and it does it out loud (roadmap item 7, rung 3)
|
|
8
|
+
|
|
9
|
+
## 0.2.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a9c235e: feat(api): anomaly rules, the authoring surface (roadmap item 4, slice 3)
|
|
14
|
+
|
|
3
15
|
## 0.2.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pgbeam
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Python SDK for the PgBeam API, a Postgres proxy for safe AI agent access with policy enforcement in the wire protocol
|
|
5
5
|
Project-URL: Homepage, https://pgbeam.com
|
|
6
6
|
Project-URL: Documentation, https://pgbeam.com/docs/python-sdk
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pgbeam"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.9"
|
|
8
8
|
description = "Python SDK for the PgBeam API, a Postgres proxy for safe AI agent access with policy enforcement in the wire protocol"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -36,6 +36,9 @@ __all__ = [
|
|
|
36
36
|
"AgentUsageMarginalRates",
|
|
37
37
|
"AgentUsageReport",
|
|
38
38
|
"AnomalyAlert",
|
|
39
|
+
"AnomalyMetric",
|
|
40
|
+
"AnomalyRule",
|
|
41
|
+
"AnomalyRuleInput",
|
|
39
42
|
"ApprovalDecisionRequest",
|
|
40
43
|
"ApprovalRequest",
|
|
41
44
|
"AssignableOrgRole",
|
|
@@ -99,6 +102,7 @@ __all__ = [
|
|
|
99
102
|
"LatencySummary",
|
|
100
103
|
"ListAgentCredentialsResponse",
|
|
101
104
|
"ListAnomalyAlertsResponse",
|
|
105
|
+
"ListAnomalyRulesResponse",
|
|
102
106
|
"ListApprovalRequestsResponse",
|
|
103
107
|
"ListAuditLogsResponse",
|
|
104
108
|
"ListCacheRulesResponse",
|
|
@@ -517,6 +521,48 @@ class AnomalyAlert(TypedDict):
|
|
|
517
521
|
acknowledged_by: NotRequired[str | None]
|
|
518
522
|
|
|
519
523
|
|
|
524
|
+
# One of the five detection metrics. A rule retunes how sensitive one of them is; it adds no detection algorithm and no alert kind.
|
|
525
|
+
AnomalyMetric = Literal[
|
|
526
|
+
"queries_per_hour", "bytes_per_hour", "distinct_shapes", "errors_per_hour", "active_hours"
|
|
527
|
+
]
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
class AnomalyRule(TypedDict):
|
|
531
|
+
"""Per-project (and optionally per-credential) sensitivity for one detection metric. Without a rule every metric resolves to the deployment default, so a noisy credential cannot be loosened, a sensitive one cannot be tightened, and off-hours cannot be silenced for a credential that legitimately runs at 3am."""
|
|
532
|
+
|
|
533
|
+
# Unique anomaly rule identifier.
|
|
534
|
+
id: str
|
|
535
|
+
# Project the rule belongs to.
|
|
536
|
+
project_id: str
|
|
537
|
+
# Agent credential the rule applies to. Null applies it to every credential in the project.
|
|
538
|
+
credential_id: NotRequired[str | None]
|
|
539
|
+
metric: AnomalyMetric
|
|
540
|
+
# N in the "mean + N * dispersion" spike rule. Null leaves the deployment default in place.
|
|
541
|
+
sigma_threshold: NotRequired[float | None]
|
|
542
|
+
# Absolute floor below which the metric never alerts. Null leaves the deployment default in place. Only queries_per_hour, bytes_per_hour and errors_per_hour have a floor.
|
|
543
|
+
floor: NotRequired[float | None]
|
|
544
|
+
# False silences this metric for this scope. Note the polarity is the opposite of honeytokens.enabled: the rule IS the switch, so disabling it disables the metric rather than deactivating the rule.
|
|
545
|
+
enabled: bool
|
|
546
|
+
# When the rule was created.
|
|
547
|
+
created_at: str
|
|
548
|
+
# When the rule was last updated.
|
|
549
|
+
updated_at: str
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
class AnomalyRuleInput(TypedDict):
|
|
553
|
+
"""Request body for creating or updating an anomaly rule. One rule exists per (project, credential, metric); creating a second for the same scope is a conflict."""
|
|
554
|
+
|
|
555
|
+
# Agent credential to scope the rule to. Null or omitted applies it to every credential in the project. The credential must belong to this project.
|
|
556
|
+
credential_id: NotRequired[str | None]
|
|
557
|
+
metric: AnomalyMetric
|
|
558
|
+
# N in the "mean + N * dispersion" spike rule. Must be greater than zero; the detector reads any value at or below zero as "use the default", so a stored zero could never mean what setting it would suggest. Rejected for distinct_shapes and active_hours, which have no rate for sigma to put a threshold on. Null or omitted leaves the deployment default in place.
|
|
559
|
+
sigma_threshold: NotRequired[float | None]
|
|
560
|
+
# Absolute floor below which the metric never alerts. Must be greater than zero, for the same reason as sigma_threshold. Rejected for distinct_shapes and active_hours, which have no rate for a floor to bound. Null or omitted leaves the deployment default in place.
|
|
561
|
+
floor: NotRequired[float | None]
|
|
562
|
+
# False silences this metric for this scope. The baseline keeps advancing while it is silenced, so re-enabling resumes from the existing history rather than a cold warm-up.
|
|
563
|
+
enabled: NotRequired[bool]
|
|
564
|
+
|
|
565
|
+
|
|
520
566
|
class ApprovalDecisionRequest(TypedDict):
|
|
521
567
|
"""Optional note attached to an approve/reject decision."""
|
|
522
568
|
|
|
@@ -1497,6 +1543,15 @@ class ListAnomalyAlertsResponse(TypedDict):
|
|
|
1497
1543
|
next_page_token: NotRequired[str]
|
|
1498
1544
|
|
|
1499
1545
|
|
|
1546
|
+
class ListAnomalyRulesResponse(TypedDict):
|
|
1547
|
+
"""Cursor-paginated anomaly rules for a project."""
|
|
1548
|
+
|
|
1549
|
+
# Anomaly rules on the current page.
|
|
1550
|
+
anomaly_rules: list[AnomalyRule]
|
|
1551
|
+
# Opaque token for cursor-based pagination.
|
|
1552
|
+
next_page_token: NotRequired[str]
|
|
1553
|
+
|
|
1554
|
+
|
|
1500
1555
|
class ListApprovalRequestsResponse(TypedDict):
|
|
1501
1556
|
"""Cursor-paginated list of approval requests for a project."""
|
|
1502
1557
|
|
|
@@ -2091,7 +2146,7 @@ class PolicyProfile(TypedDict):
|
|
|
2091
2146
|
egress_bytes_per_day: NotRequired[int]
|
|
2092
2147
|
# Hard cap on rows a single write (INSERT/UPDATE/DELETE) may affect. A write whose affected-row count would exceed this is executed inside a transaction, checked, and rolled back so nothing persists, then blocked. Enforced independently of human approval. 0 means unlimited.
|
|
2093
2148
|
max_affected_rows: NotRequired[int]
|
|
2094
|
-
# Result-content scanning, enforced on the data-plane relay path: values on their way out to an agent are checked for instruction-shaped content (stored prompt injection). off scans nothing and costs nothing. annotate scans and forwards every value unchanged, recording what it found. block
|
|
2149
|
+
# Result-content scanning, enforced on the data-plane relay path: values on their way out to an agent are checked for instruction-shaped content (stored prompt injection). off scans nothing and costs nothing. annotate scans and forwards every value unchanged, recording what it found. block scans the same way and refuses instead: a value the structural detectors report at high confidence withholds that row and the rest of the exchange, and the statement's completion is replaced with an error (SQLSTATE 42501) naming the column, so a withheld result reads as a failed statement rather than a short one. Rows the scan had already cleared stay delivered, because this is a streaming protocol; what block guarantees is that no value carrying such a finding is ever sent to the agent. A lower-confidence finding never refuses, under any mode. No mode rewrites a value or withholds a row without saying so. A flagged statement records one content_flagged audit entry naming the columns, the techniques and whether the scan covered the whole result, alongside the proxy's own metrics and logs; the entry carries no value from the row itself, and it is delivered to any endpoint subscribed to the content_flagged webhook event, at either confidence, with decision_rule telling them apart. A finding the structural detectors report at high confidence also raises an anomaly alert, at most one per credential per hour; lower-confidence findings stay in the audit trail and the webhook stream. Values the scan cannot read (binary-format columns, columns this profile masks, and anything past content_scan_max_bytes) are counted as unscanned rather than reported clean. A proxy build older than result-content scanning ignores this field.
|
|
2095
2150
|
content_scan_mode: NotRequired[Literal["off", "annotate", "block"]]
|
|
2096
2151
|
# Byte budget for one statement's content scan, spanning all values in the result. Values past it are reported unscannable rather than skipped quietly. The budget covers a whole statement, so the statements of one simple-query batch share it rather than each getting a fresh allowance. 0 uses the scanner default (4 MiB), which covers an interactive result set and deliberately does not cover a bulk export.
|
|
2097
2152
|
content_scan_max_bytes: NotRequired[int]
|
|
@@ -2139,7 +2194,7 @@ class PolicyProfileInput(TypedDict):
|
|
|
2139
2194
|
egress_bytes_per_day: NotRequired[int]
|
|
2140
2195
|
# Hard cap on rows a single write (INSERT/UPDATE/DELETE) may affect. A write whose affected-row count would exceed this is executed inside a transaction, checked, and rolled back so nothing persists, then blocked. Enforced independently of human approval. 0 means unlimited.
|
|
2141
2196
|
max_affected_rows: NotRequired[int]
|
|
2142
|
-
# Result-content scanning, enforced on the data-plane relay path: values on their way out to an agent are checked for instruction-shaped content (stored prompt injection). off scans nothing and costs nothing. annotate scans and forwards every value unchanged, recording what it found. block
|
|
2197
|
+
# Result-content scanning, enforced on the data-plane relay path: values on their way out to an agent are checked for instruction-shaped content (stored prompt injection). off scans nothing and costs nothing. annotate scans and forwards every value unchanged, recording what it found. block scans the same way and refuses instead: a value the structural detectors report at high confidence withholds that row and the rest of the exchange, and the statement's completion is replaced with an error (SQLSTATE 42501) naming the column, so a withheld result reads as a failed statement rather than a short one. Rows the scan had already cleared stay delivered, because this is a streaming protocol; what block guarantees is that no value carrying such a finding is ever sent to the agent. A lower-confidence finding never refuses, under any mode. No mode rewrites a value or withholds a row without saying so. A flagged statement records one content_flagged audit entry naming the columns, the techniques and whether the scan covered the whole result, alongside the proxy's own metrics and logs; the entry carries no value from the row itself, and it is delivered to any endpoint subscribed to the content_flagged webhook event, at either confidence, with decision_rule telling them apart. A finding the structural detectors report at high confidence also raises an anomaly alert, at most one per credential per hour; lower-confidence findings stay in the audit trail and the webhook stream. Values the scan cannot read (binary-format columns, columns this profile masks, and anything past content_scan_max_bytes) are counted as unscanned rather than reported clean. A proxy build older than result-content scanning ignores this field.
|
|
2143
2198
|
content_scan_mode: NotRequired[Literal["off", "annotate", "block"]]
|
|
2144
2199
|
# Byte budget for one statement's content scan, spanning all values in the result. Values past it are reported unscannable rather than skipped quietly. The budget covers a whole statement, so the statements of one simple-query batch share it rather than each getting a fresh allowance. 0 uses the scanner default (4 MiB), which covers an interactive result set and deliberately does not cover a bulk export.
|
|
2145
2200
|
content_scan_max_bytes: NotRequired[int]
|
|
@@ -2939,6 +2994,7 @@ WebhookEventType = Literal[
|
|
|
2939
2994
|
"approval_requested",
|
|
2940
2995
|
"anomaly_alert",
|
|
2941
2996
|
"canary_tripped",
|
|
2997
|
+
"content_flagged",
|
|
2942
2998
|
"audit_checkpoint",
|
|
2943
2999
|
"webhook.test",
|
|
2944
3000
|
]
|
|
@@ -161,6 +161,17 @@ OPERATIONS_BY_TAG: dict[str, dict[str, OperationMeta]] = {
|
|
|
161
161
|
"update_anomaly_alert": OperationMeta(
|
|
162
162
|
"PATCH", "/v1/projects/{project_id}/anomalies/{anomaly_id}"
|
|
163
163
|
),
|
|
164
|
+
"list_anomaly_rules": OperationMeta("GET", "/v1/projects/{project_id}/anomaly-rules"),
|
|
165
|
+
"create_anomaly_rule": OperationMeta("POST", "/v1/projects/{project_id}/anomaly-rules"),
|
|
166
|
+
"get_anomaly_rule": OperationMeta(
|
|
167
|
+
"GET", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
168
|
+
),
|
|
169
|
+
"update_anomaly_rule": OperationMeta(
|
|
170
|
+
"PUT", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
171
|
+
),
|
|
172
|
+
"delete_anomaly_rule": OperationMeta(
|
|
173
|
+
"DELETE", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
174
|
+
),
|
|
164
175
|
},
|
|
165
176
|
"branches": {
|
|
166
177
|
"list_database_branches": OperationMeta("GET", "/v1/projects/{project_id}/branches"),
|
|
@@ -283,6 +294,21 @@ OPERATIONS_BY_PATH: dict[str, OperationMeta] = {
|
|
|
283
294
|
"PATCH /v1/projects/{project_id}/anomalies/{anomaly_id}": OperationMeta(
|
|
284
295
|
"PATCH", "/v1/projects/{project_id}/anomalies/{anomaly_id}"
|
|
285
296
|
),
|
|
297
|
+
"GET /v1/projects/{project_id}/anomaly-rules": OperationMeta(
|
|
298
|
+
"GET", "/v1/projects/{project_id}/anomaly-rules"
|
|
299
|
+
),
|
|
300
|
+
"POST /v1/projects/{project_id}/anomaly-rules": OperationMeta(
|
|
301
|
+
"POST", "/v1/projects/{project_id}/anomaly-rules"
|
|
302
|
+
),
|
|
303
|
+
"GET /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}": OperationMeta(
|
|
304
|
+
"GET", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
305
|
+
),
|
|
306
|
+
"PUT /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}": OperationMeta(
|
|
307
|
+
"PUT", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
308
|
+
),
|
|
309
|
+
"DELETE /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}": OperationMeta(
|
|
310
|
+
"DELETE", "/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}"
|
|
311
|
+
),
|
|
286
312
|
"GET /v1/projects/{project_id}/approvals": OperationMeta(
|
|
287
313
|
"GET", "/v1/projects/{project_id}/approvals"
|
|
288
314
|
),
|
|
@@ -19,6 +19,8 @@ from .models import (
|
|
|
19
19
|
AgentCredentialSecrets,
|
|
20
20
|
AgentUsageReport,
|
|
21
21
|
AnomalyAlert,
|
|
22
|
+
AnomalyRule,
|
|
23
|
+
AnomalyRuleInput,
|
|
22
24
|
ApprovalDecisionRequest,
|
|
23
25
|
ApprovalRequest,
|
|
24
26
|
AuditChainVerification,
|
|
@@ -54,6 +56,7 @@ from .models import (
|
|
|
54
56
|
HoneytokenInput,
|
|
55
57
|
ListAgentCredentialsResponse,
|
|
56
58
|
ListAnomalyAlertsResponse,
|
|
59
|
+
ListAnomalyRulesResponse,
|
|
57
60
|
ListApprovalRequestsResponse,
|
|
58
61
|
ListAuditLogsResponse,
|
|
59
62
|
ListCacheRulesResponse,
|
|
@@ -2065,6 +2068,150 @@ class AnomaliesService:
|
|
|
2065
2068
|
),
|
|
2066
2069
|
)
|
|
2067
2070
|
|
|
2071
|
+
def list_anomaly_rules(
|
|
2072
|
+
self,
|
|
2073
|
+
project_id: str,
|
|
2074
|
+
*,
|
|
2075
|
+
page_size: int | None = None,
|
|
2076
|
+
page_token: str | None = None,
|
|
2077
|
+
) -> ListAnomalyRulesResponse:
|
|
2078
|
+
"""List anomaly rules.
|
|
2079
|
+
|
|
2080
|
+
Lists the project's anomaly rules, including silenced ones.
|
|
2081
|
+
|
|
2082
|
+
``GET /v1/projects/{project_id}/anomaly-rules``
|
|
2083
|
+
|
|
2084
|
+
Args:
|
|
2085
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
2086
|
+
page_size: Maximum number of items to return (1-100, default 20).
|
|
2087
|
+
page_token: Opaque token for cursor-based pagination.
|
|
2088
|
+
"""
|
|
2089
|
+
return cast(
|
|
2090
|
+
ListAnomalyRulesResponse,
|
|
2091
|
+
self._transport.request(
|
|
2092
|
+
"GET",
|
|
2093
|
+
"/v1/projects/{project_id}/anomaly-rules",
|
|
2094
|
+
path_params={
|
|
2095
|
+
"project_id": project_id,
|
|
2096
|
+
},
|
|
2097
|
+
query={
|
|
2098
|
+
"page_size": page_size,
|
|
2099
|
+
"page_token": page_token,
|
|
2100
|
+
},
|
|
2101
|
+
),
|
|
2102
|
+
)
|
|
2103
|
+
|
|
2104
|
+
def create_anomaly_rule(
|
|
2105
|
+
self,
|
|
2106
|
+
project_id: str,
|
|
2107
|
+
*,
|
|
2108
|
+
body: AnomalyRuleInput,
|
|
2109
|
+
) -> AnomalyRule:
|
|
2110
|
+
"""Create an anomaly rule.
|
|
2111
|
+
|
|
2112
|
+
Retunes one detection metric for this project, or for one agent credential in it. Without a rule every metric resolves to the deployment default. A rule adds no detection algorithm and no alert kind: it changes how sensitive one of the five existing metrics is. enabled=false silences that metric for that scope; the baseline keeps advancing, so re-enabling resumes from the existing history rather than a cold warm-up.
|
|
2113
|
+
|
|
2114
|
+
``POST /v1/projects/{project_id}/anomaly-rules``
|
|
2115
|
+
|
|
2116
|
+
Args:
|
|
2117
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
2118
|
+
body: The request body.
|
|
2119
|
+
"""
|
|
2120
|
+
return cast(
|
|
2121
|
+
AnomalyRule,
|
|
2122
|
+
self._transport.request(
|
|
2123
|
+
"POST",
|
|
2124
|
+
"/v1/projects/{project_id}/anomaly-rules",
|
|
2125
|
+
path_params={
|
|
2126
|
+
"project_id": project_id,
|
|
2127
|
+
},
|
|
2128
|
+
body=body,
|
|
2129
|
+
),
|
|
2130
|
+
)
|
|
2131
|
+
|
|
2132
|
+
def get_anomaly_rule(
|
|
2133
|
+
self,
|
|
2134
|
+
project_id: str,
|
|
2135
|
+
anomaly_rule_id: str,
|
|
2136
|
+
) -> AnomalyRule:
|
|
2137
|
+
"""Get an anomaly rule.
|
|
2138
|
+
|
|
2139
|
+
Returns a single anomaly rule by ID.
|
|
2140
|
+
|
|
2141
|
+
``GET /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
2142
|
+
|
|
2143
|
+
Args:
|
|
2144
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
2145
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
2146
|
+
"""
|
|
2147
|
+
return cast(
|
|
2148
|
+
AnomalyRule,
|
|
2149
|
+
self._transport.request(
|
|
2150
|
+
"GET",
|
|
2151
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
2152
|
+
path_params={
|
|
2153
|
+
"project_id": project_id,
|
|
2154
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
2155
|
+
},
|
|
2156
|
+
),
|
|
2157
|
+
)
|
|
2158
|
+
|
|
2159
|
+
def update_anomaly_rule(
|
|
2160
|
+
self,
|
|
2161
|
+
project_id: str,
|
|
2162
|
+
anomaly_rule_id: str,
|
|
2163
|
+
*,
|
|
2164
|
+
body: AnomalyRuleInput,
|
|
2165
|
+
) -> AnomalyRule:
|
|
2166
|
+
"""Update an anomaly rule.
|
|
2167
|
+
|
|
2168
|
+
Replaces the rule's scope, metric and sensitivity. A rule whose enabled flag is turned off silences its metric for its scope rather than being deactivated.
|
|
2169
|
+
|
|
2170
|
+
``PUT /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
2171
|
+
|
|
2172
|
+
Args:
|
|
2173
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
2174
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
2175
|
+
body: The request body.
|
|
2176
|
+
"""
|
|
2177
|
+
return cast(
|
|
2178
|
+
AnomalyRule,
|
|
2179
|
+
self._transport.request(
|
|
2180
|
+
"PUT",
|
|
2181
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
2182
|
+
path_params={
|
|
2183
|
+
"project_id": project_id,
|
|
2184
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
2185
|
+
},
|
|
2186
|
+
body=body,
|
|
2187
|
+
),
|
|
2188
|
+
)
|
|
2189
|
+
|
|
2190
|
+
def delete_anomaly_rule(
|
|
2191
|
+
self,
|
|
2192
|
+
project_id: str,
|
|
2193
|
+
anomaly_rule_id: str,
|
|
2194
|
+
) -> None:
|
|
2195
|
+
"""Delete an anomaly rule.
|
|
2196
|
+
|
|
2197
|
+
Removes the rule, so its metric returns to the deployment default for that scope. Deleting a rule that was silencing a metric turns that metric's alerts back on.
|
|
2198
|
+
|
|
2199
|
+
``DELETE /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
2200
|
+
|
|
2201
|
+
Args:
|
|
2202
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
2203
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
2204
|
+
"""
|
|
2205
|
+
self._transport.request(
|
|
2206
|
+
"DELETE",
|
|
2207
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
2208
|
+
path_params={
|
|
2209
|
+
"project_id": project_id,
|
|
2210
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
2211
|
+
},
|
|
2212
|
+
)
|
|
2213
|
+
return None
|
|
2214
|
+
|
|
2068
2215
|
|
|
2069
2216
|
class BranchesService:
|
|
2070
2217
|
"""The Branches operations, blocking. Reached as ``client.branches``."""
|
|
@@ -5092,6 +5239,150 @@ class AsyncAnomaliesService:
|
|
|
5092
5239
|
),
|
|
5093
5240
|
)
|
|
5094
5241
|
|
|
5242
|
+
async def list_anomaly_rules(
|
|
5243
|
+
self,
|
|
5244
|
+
project_id: str,
|
|
5245
|
+
*,
|
|
5246
|
+
page_size: int | None = None,
|
|
5247
|
+
page_token: str | None = None,
|
|
5248
|
+
) -> ListAnomalyRulesResponse:
|
|
5249
|
+
"""List anomaly rules.
|
|
5250
|
+
|
|
5251
|
+
Lists the project's anomaly rules, including silenced ones.
|
|
5252
|
+
|
|
5253
|
+
``GET /v1/projects/{project_id}/anomaly-rules``
|
|
5254
|
+
|
|
5255
|
+
Args:
|
|
5256
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
5257
|
+
page_size: Maximum number of items to return (1-100, default 20).
|
|
5258
|
+
page_token: Opaque token for cursor-based pagination.
|
|
5259
|
+
"""
|
|
5260
|
+
return cast(
|
|
5261
|
+
ListAnomalyRulesResponse,
|
|
5262
|
+
await self._transport.request(
|
|
5263
|
+
"GET",
|
|
5264
|
+
"/v1/projects/{project_id}/anomaly-rules",
|
|
5265
|
+
path_params={
|
|
5266
|
+
"project_id": project_id,
|
|
5267
|
+
},
|
|
5268
|
+
query={
|
|
5269
|
+
"page_size": page_size,
|
|
5270
|
+
"page_token": page_token,
|
|
5271
|
+
},
|
|
5272
|
+
),
|
|
5273
|
+
)
|
|
5274
|
+
|
|
5275
|
+
async def create_anomaly_rule(
|
|
5276
|
+
self,
|
|
5277
|
+
project_id: str,
|
|
5278
|
+
*,
|
|
5279
|
+
body: AnomalyRuleInput,
|
|
5280
|
+
) -> AnomalyRule:
|
|
5281
|
+
"""Create an anomaly rule.
|
|
5282
|
+
|
|
5283
|
+
Retunes one detection metric for this project, or for one agent credential in it. Without a rule every metric resolves to the deployment default. A rule adds no detection algorithm and no alert kind: it changes how sensitive one of the five existing metrics is. enabled=false silences that metric for that scope; the baseline keeps advancing, so re-enabling resumes from the existing history rather than a cold warm-up.
|
|
5284
|
+
|
|
5285
|
+
``POST /v1/projects/{project_id}/anomaly-rules``
|
|
5286
|
+
|
|
5287
|
+
Args:
|
|
5288
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
5289
|
+
body: The request body.
|
|
5290
|
+
"""
|
|
5291
|
+
return cast(
|
|
5292
|
+
AnomalyRule,
|
|
5293
|
+
await self._transport.request(
|
|
5294
|
+
"POST",
|
|
5295
|
+
"/v1/projects/{project_id}/anomaly-rules",
|
|
5296
|
+
path_params={
|
|
5297
|
+
"project_id": project_id,
|
|
5298
|
+
},
|
|
5299
|
+
body=body,
|
|
5300
|
+
),
|
|
5301
|
+
)
|
|
5302
|
+
|
|
5303
|
+
async def get_anomaly_rule(
|
|
5304
|
+
self,
|
|
5305
|
+
project_id: str,
|
|
5306
|
+
anomaly_rule_id: str,
|
|
5307
|
+
) -> AnomalyRule:
|
|
5308
|
+
"""Get an anomaly rule.
|
|
5309
|
+
|
|
5310
|
+
Returns a single anomaly rule by ID.
|
|
5311
|
+
|
|
5312
|
+
``GET /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
5313
|
+
|
|
5314
|
+
Args:
|
|
5315
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
5316
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
5317
|
+
"""
|
|
5318
|
+
return cast(
|
|
5319
|
+
AnomalyRule,
|
|
5320
|
+
await self._transport.request(
|
|
5321
|
+
"GET",
|
|
5322
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
5323
|
+
path_params={
|
|
5324
|
+
"project_id": project_id,
|
|
5325
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
5326
|
+
},
|
|
5327
|
+
),
|
|
5328
|
+
)
|
|
5329
|
+
|
|
5330
|
+
async def update_anomaly_rule(
|
|
5331
|
+
self,
|
|
5332
|
+
project_id: str,
|
|
5333
|
+
anomaly_rule_id: str,
|
|
5334
|
+
*,
|
|
5335
|
+
body: AnomalyRuleInput,
|
|
5336
|
+
) -> AnomalyRule:
|
|
5337
|
+
"""Update an anomaly rule.
|
|
5338
|
+
|
|
5339
|
+
Replaces the rule's scope, metric and sensitivity. A rule whose enabled flag is turned off silences its metric for its scope rather than being deactivated.
|
|
5340
|
+
|
|
5341
|
+
``PUT /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
5342
|
+
|
|
5343
|
+
Args:
|
|
5344
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
5345
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
5346
|
+
body: The request body.
|
|
5347
|
+
"""
|
|
5348
|
+
return cast(
|
|
5349
|
+
AnomalyRule,
|
|
5350
|
+
await self._transport.request(
|
|
5351
|
+
"PUT",
|
|
5352
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
5353
|
+
path_params={
|
|
5354
|
+
"project_id": project_id,
|
|
5355
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
5356
|
+
},
|
|
5357
|
+
body=body,
|
|
5358
|
+
),
|
|
5359
|
+
)
|
|
5360
|
+
|
|
5361
|
+
async def delete_anomaly_rule(
|
|
5362
|
+
self,
|
|
5363
|
+
project_id: str,
|
|
5364
|
+
anomaly_rule_id: str,
|
|
5365
|
+
) -> None:
|
|
5366
|
+
"""Delete an anomaly rule.
|
|
5367
|
+
|
|
5368
|
+
Removes the rule, so its metric returns to the deployment default for that scope. Deleting a rule that was silencing a metric turns that metric's alerts back on.
|
|
5369
|
+
|
|
5370
|
+
``DELETE /v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}``
|
|
5371
|
+
|
|
5372
|
+
Args:
|
|
5373
|
+
project_id: Unique project identifier (prefixed, e.g. prj_xxx).
|
|
5374
|
+
anomaly_rule_id: Unique anomaly rule identifier (prefixed, e.g. anr_xxx).
|
|
5375
|
+
"""
|
|
5376
|
+
await self._transport.request(
|
|
5377
|
+
"DELETE",
|
|
5378
|
+
"/v1/projects/{project_id}/anomaly-rules/{anomaly_rule_id}",
|
|
5379
|
+
path_params={
|
|
5380
|
+
"project_id": project_id,
|
|
5381
|
+
"anomaly_rule_id": anomaly_rule_id,
|
|
5382
|
+
},
|
|
5383
|
+
)
|
|
5384
|
+
return None
|
|
5385
|
+
|
|
5095
5386
|
|
|
5096
5387
|
class AsyncBranchesService:
|
|
5097
5388
|
"""The Branches operations, awaitable. Reached as ``client.branches``."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|