stackgen-sdk 0.1.1__py3-none-any.whl

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.
Files changed (73) hide show
  1. stackgen/__init__.py +52 -0
  2. stackgen/_http.py +96 -0
  3. stackgen/_version.py +24 -0
  4. stackgen/aiden/__init__.py +9 -0
  5. stackgen/aiden/namespace.py +26 -0
  6. stackgen/aiden/runs.py +36 -0
  7. stackgen/aiden/webhook.py +185 -0
  8. stackgen/cli.py +33 -0
  9. stackgen/client.py +31 -0
  10. stackgen/config.py +88 -0
  11. stackgen/errors.py +41 -0
  12. stackgen/generated/.openapi-generator/FILES +141 -0
  13. stackgen/generated/.openapi-generator/VERSION +1 -0
  14. stackgen/generated/.openapi-generator-ignore +23 -0
  15. stackgen/generated/__init__.py +131 -0
  16. stackgen/generated/api/__init__.py +6 -0
  17. stackgen/generated/api/aiden_api.py +1806 -0
  18. stackgen/generated/api/sre_api.py +1618 -0
  19. stackgen/generated/api_client.py +801 -0
  20. stackgen/generated/api_response.py +21 -0
  21. stackgen/generated/configuration.py +600 -0
  22. stackgen/generated/exceptions.py +216 -0
  23. stackgen/generated/models/__init__.py +57 -0
  24. stackgen/generated/models/alert_analysis_status.py +40 -0
  25. stackgen/generated/models/alert_attention.py +39 -0
  26. stackgen/generated/models/alert_categorization_summary.py +97 -0
  27. stackgen/generated/models/alert_role.py +38 -0
  28. stackgen/generated/models/alert_sort_by.py +37 -0
  29. stackgen/generated/models/alert_status.py +38 -0
  30. stackgen/generated/models/alert_summary.py +95 -0
  31. stackgen/generated/models/alert_sync_run_status.py +38 -0
  32. stackgen/generated/models/alert_v1.py +213 -0
  33. stackgen/generated/models/artifact_info.py +98 -0
  34. stackgen/generated/models/error_response.py +91 -0
  35. stackgen/generated/models/investigate_alert_request.py +91 -0
  36. stackgen/generated/models/investigate_response.py +91 -0
  37. stackgen/generated/models/investigation.py +167 -0
  38. stackgen/generated/models/investigation_evidence.py +114 -0
  39. stackgen/generated/models/investigation_evidence_kind.py +44 -0
  40. stackgen/generated/models/investigation_evidence_source.py +39 -0
  41. stackgen/generated/models/investigation_hypothesis.py +112 -0
  42. stackgen/generated/models/investigation_plain_summary.py +104 -0
  43. stackgen/generated/models/investigation_prior_incident.py +109 -0
  44. stackgen/generated/models/investigation_recommended_next_step.py +101 -0
  45. stackgen/generated/models/investigation_ref.py +118 -0
  46. stackgen/generated/models/investigation_status.py +42 -0
  47. stackgen/generated/models/investigation_structured_hypothesis_entry.py +115 -0
  48. stackgen/generated/models/investigation_structured_limitation_entry.py +120 -0
  49. stackgen/generated/models/investigation_structured_rca.py +139 -0
  50. stackgen/generated/models/investigation_triage_metadata.py +134 -0
  51. stackgen/generated/models/json_error.py +91 -0
  52. stackgen/generated/models/list_alerts_response.py +119 -0
  53. stackgen/generated/models/list_investigations_response.py +101 -0
  54. stackgen/generated/models/pagination.py +91 -0
  55. stackgen/generated/models/schedule_run_status.py +39 -0
  56. stackgen/generated/models/schedule_target_type.py +38 -0
  57. stackgen/generated/models/session.py +141 -0
  58. stackgen/generated/models/session_responder_kind.py +40 -0
  59. stackgen/generated/models/signal_severity.py +40 -0
  60. stackgen/generated/models/sync_response.py +136 -0
  61. stackgen/generated/models/trigger_webhook202_response.py +98 -0
  62. stackgen/generated/models/webhook_run.py +129 -0
  63. stackgen/generated/models/webhook_run_detail.py +136 -0
  64. stackgen/generated/models/webhook_run_list_response.py +97 -0
  65. stackgen/generated/rest.py +258 -0
  66. stackgen/sre/__init__.py +5 -0
  67. stackgen/sre/namespace.py +57 -0
  68. stackgen/vault/__init__.py +5 -0
  69. stackgen/vault/namespace.py +17 -0
  70. stackgen_sdk-0.1.1.dist-info/METADATA +60 -0
  71. stackgen_sdk-0.1.1.dist-info/RECORD +73 -0
  72. stackgen_sdk-0.1.1.dist-info/WHEEL +4 -0
  73. stackgen_sdk-0.1.1.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import json
17
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class AlertSyncRunStatus(str, Enum):
22
+ """
23
+ Status of an alert sync run (manual, scheduled, or webhook-triggered).
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ RUNNING = 'running'
30
+ COMPLETED = 'completed'
31
+ FAILED = 'failed'
32
+
33
+ @classmethod
34
+ def from_json(cls, json_str: str) -> Self:
35
+ """Create an instance of AlertSyncRunStatus from a JSON string"""
36
+ return cls(json.loads(json_str))
37
+
38
+
@@ -0,0 +1,213 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from stackgen.generated.models.alert_analysis_status import AlertAnalysisStatus
25
+ from stackgen.generated.models.alert_attention import AlertAttention
26
+ from stackgen.generated.models.alert_role import AlertRole
27
+ from stackgen.generated.models.alert_status import AlertStatus
28
+ from stackgen.generated.models.investigation_ref import InvestigationRef
29
+ from typing import Optional, Set
30
+ from typing_extensions import Self
31
+
32
+ class AlertV1(BaseModel):
33
+ """
34
+ A single alert with its current lifecycle, analysis, and triage state.
35
+ """ # noqa: E501
36
+ id: StrictStr = Field(description="Internal alert UUID.")
37
+ external_uid: StrictStr = Field(description="Stable identifier from the alert source (e.g. Grafana fingerprint).")
38
+ source_type: StrictStr = Field(description="Alert source system (e.g. \"grafana\").")
39
+ integration_name: Optional[StrictStr] = Field(default=None, description="Human-readable name of the integration that produced this alert.")
40
+ title: StrictStr = Field(description="Short human-readable alert title.")
41
+ description: StrictStr = Field(description="Longer description or message from the alert source.")
42
+ source_severity: StrictStr = Field(description="Raw severity string from the source (e.g. \"critical\", \"high\").")
43
+ display_priority: StrictInt = Field(description="Numeric sort key derived from severity (lower = more urgent).")
44
+ impact_score: Annotated[int, Field(le=100, strict=True, ge=0)] = Field(description="Estimated blast-radius impact (0–100, higher = greater impact). Derived at ingest from environment criticality, label scope breadth, and co-firing storm fanout — not from monitor severity. ")
45
+ impact_explanation: Optional[StrictStr] = Field(default=None, description="Plain-English rationale for impact_score (e.g. prod environment, three co-firing peers) so operators can trust impact sorting. ")
46
+ status: AlertStatus
47
+ analysis_status: AlertAnalysisStatus
48
+ attention: AlertAttention
49
+ attention_reason: Optional[StrictStr] = Field(default=None, description="Plain-English explanation for the attention classification.")
50
+ ignore_reason: Optional[StrictStr] = Field(default=None, description="Plain-English reason the operator provided when ignoring this alert.")
51
+ short_summary: Optional[StrictStr] = Field(default=None, description="One-liner produced by Aiden auto-analysis (sre_classify_alert_criticality) summarising what is happening with this alert. Rendered inline in the alerts list and queue ahead of the full investigation result.")
52
+ initial_investigation: Optional[StrictStr] = Field(default=None, description="First-pass write-up produced by Aiden auto-analysis. Multi-line text with hypotheses, related signals, and suggested next steps; rendered as the headline body in the alert detail drawer before the deep-dive investigation completes.")
53
+ triggered_at: datetime = Field(description="When the alert last fired (most recent trigger from the source).")
54
+ created_at: datetime = Field(description="When the alert was first triggered and ingested into SRE (unchanged on re-fires).")
55
+ resolved_at: Optional[datetime] = Field(default=None, description="When the alert was last resolved.")
56
+ refire_count: StrictInt = Field(description="Number of times this alert has re-fired after being resolved.")
57
+ last_resolved_at: Optional[datetime] = Field(default=None, description="Timestamp of the most recent resolution (before a re-fire).")
58
+ investigation: Optional[InvestigationRef] = None
59
+ labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="User-facing alert labels from the monitoring source (e.g. Grafana Prometheus labels). Internal system keys are stripped before persistence.")
60
+ alert_role: Optional[AlertRole] = None
61
+ storm_id: Optional[StrictStr] = Field(default=None, description="UUID grouping co-firing alerts in the same incident storm. Null when the alert is isolated or not yet correlated.")
62
+ likely_upstream: Optional[StrictStr] = Field(default=None, description="For symptom alerts, a plain-English hint naming the most likely upstream cause alert or service in the same storm.")
63
+ ingested_via: Optional[StrictStr] = Field(default=None, description="Ingestion-mode tag for this alert's current episode: \"push\" (webhook) or \"pull\" (scheduled/manual sync). Set on first ingest and on re-fire from resolved; left unchanged on plain updates.")
64
+ raw_payload: Optional[StrictStr] = Field(default=None, description="Source-native payload the ingestion/auto-investigate filters run on, stored verbatim as JSON text — the raw webhook body for push, or the marshalled source object for pull. Null on legacy rows ingested before raw-payload capture.")
65
+ __properties: ClassVar[List[str]] = ["id", "external_uid", "source_type", "integration_name", "title", "description", "source_severity", "display_priority", "impact_score", "impact_explanation", "status", "analysis_status", "attention", "attention_reason", "ignore_reason", "short_summary", "initial_investigation", "triggered_at", "created_at", "resolved_at", "refire_count", "last_resolved_at", "investigation", "labels", "alert_role", "storm_id", "likely_upstream", "ingested_via", "raw_payload"]
66
+
67
+ model_config = ConfigDict(
68
+ populate_by_name=True,
69
+ validate_assignment=True,
70
+ protected_namespaces=(),
71
+ )
72
+
73
+
74
+ def to_str(self) -> str:
75
+ """Returns the string representation of the model using alias"""
76
+ return pprint.pformat(self.model_dump(by_alias=True))
77
+
78
+ def to_json(self) -> str:
79
+ """Returns the JSON representation of the model using alias"""
80
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
81
+ return json.dumps(self.to_dict())
82
+
83
+ @classmethod
84
+ def from_json(cls, json_str: str) -> Optional[Self]:
85
+ """Create an instance of AlertV1 from a JSON string"""
86
+ return cls.from_dict(json.loads(json_str))
87
+
88
+ def to_dict(self) -> Dict[str, Any]:
89
+ """Return the dictionary representation of the model using alias.
90
+
91
+ This has the following differences from calling pydantic's
92
+ `self.model_dump(by_alias=True)`:
93
+
94
+ * `None` is only added to the output dict for nullable fields that
95
+ were set at model initialization. Other fields with value `None`
96
+ are ignored.
97
+ """
98
+ excluded_fields: Set[str] = set([
99
+ ])
100
+
101
+ _dict = self.model_dump(
102
+ by_alias=True,
103
+ exclude=excluded_fields,
104
+ exclude_none=True,
105
+ )
106
+ # override the default output from pydantic by calling `to_dict()` of investigation
107
+ if self.investigation:
108
+ _dict['investigation'] = self.investigation.to_dict()
109
+ # set to None if integration_name (nullable) is None
110
+ # and model_fields_set contains the field
111
+ if self.integration_name is None and "integration_name" in self.model_fields_set:
112
+ _dict['integration_name'] = None
113
+
114
+ # set to None if impact_explanation (nullable) is None
115
+ # and model_fields_set contains the field
116
+ if self.impact_explanation is None and "impact_explanation" in self.model_fields_set:
117
+ _dict['impact_explanation'] = None
118
+
119
+ # set to None if attention_reason (nullable) is None
120
+ # and model_fields_set contains the field
121
+ if self.attention_reason is None and "attention_reason" in self.model_fields_set:
122
+ _dict['attention_reason'] = None
123
+
124
+ # set to None if ignore_reason (nullable) is None
125
+ # and model_fields_set contains the field
126
+ if self.ignore_reason is None and "ignore_reason" in self.model_fields_set:
127
+ _dict['ignore_reason'] = None
128
+
129
+ # set to None if short_summary (nullable) is None
130
+ # and model_fields_set contains the field
131
+ if self.short_summary is None and "short_summary" in self.model_fields_set:
132
+ _dict['short_summary'] = None
133
+
134
+ # set to None if initial_investigation (nullable) is None
135
+ # and model_fields_set contains the field
136
+ if self.initial_investigation is None and "initial_investigation" in self.model_fields_set:
137
+ _dict['initial_investigation'] = None
138
+
139
+ # set to None if resolved_at (nullable) is None
140
+ # and model_fields_set contains the field
141
+ if self.resolved_at is None and "resolved_at" in self.model_fields_set:
142
+ _dict['resolved_at'] = None
143
+
144
+ # set to None if last_resolved_at (nullable) is None
145
+ # and model_fields_set contains the field
146
+ if self.last_resolved_at is None and "last_resolved_at" in self.model_fields_set:
147
+ _dict['last_resolved_at'] = None
148
+
149
+ # set to None if storm_id (nullable) is None
150
+ # and model_fields_set contains the field
151
+ if self.storm_id is None and "storm_id" in self.model_fields_set:
152
+ _dict['storm_id'] = None
153
+
154
+ # set to None if likely_upstream (nullable) is None
155
+ # and model_fields_set contains the field
156
+ if self.likely_upstream is None and "likely_upstream" in self.model_fields_set:
157
+ _dict['likely_upstream'] = None
158
+
159
+ # set to None if ingested_via (nullable) is None
160
+ # and model_fields_set contains the field
161
+ if self.ingested_via is None and "ingested_via" in self.model_fields_set:
162
+ _dict['ingested_via'] = None
163
+
164
+ # set to None if raw_payload (nullable) is None
165
+ # and model_fields_set contains the field
166
+ if self.raw_payload is None and "raw_payload" in self.model_fields_set:
167
+ _dict['raw_payload'] = None
168
+
169
+ return _dict
170
+
171
+ @classmethod
172
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
173
+ """Create an instance of AlertV1 from a dict"""
174
+ if obj is None:
175
+ return None
176
+
177
+ if not isinstance(obj, dict):
178
+ return cls.model_validate(obj)
179
+
180
+ _obj = cls.model_validate({
181
+ "id": obj.get("id"),
182
+ "external_uid": obj.get("external_uid"),
183
+ "source_type": obj.get("source_type"),
184
+ "integration_name": obj.get("integration_name"),
185
+ "title": obj.get("title"),
186
+ "description": obj.get("description"),
187
+ "source_severity": obj.get("source_severity"),
188
+ "display_priority": obj.get("display_priority"),
189
+ "impact_score": obj.get("impact_score"),
190
+ "impact_explanation": obj.get("impact_explanation"),
191
+ "status": obj.get("status"),
192
+ "analysis_status": obj.get("analysis_status"),
193
+ "attention": obj.get("attention"),
194
+ "attention_reason": obj.get("attention_reason"),
195
+ "ignore_reason": obj.get("ignore_reason"),
196
+ "short_summary": obj.get("short_summary"),
197
+ "initial_investigation": obj.get("initial_investigation"),
198
+ "triggered_at": obj.get("triggered_at"),
199
+ "created_at": obj.get("created_at"),
200
+ "resolved_at": obj.get("resolved_at"),
201
+ "refire_count": obj.get("refire_count"),
202
+ "last_resolved_at": obj.get("last_resolved_at"),
203
+ "investigation": InvestigationRef.from_dict(obj["investigation"]) if obj.get("investigation") is not None else None,
204
+ "labels": obj.get("labels"),
205
+ "alert_role": obj.get("alert_role"),
206
+ "storm_id": obj.get("storm_id"),
207
+ "likely_upstream": obj.get("likely_upstream"),
208
+ "ingested_via": obj.get("ingested_via"),
209
+ "raw_payload": obj.get("raw_payload")
210
+ })
211
+ return _obj
212
+
213
+
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ArtifactInfo(BaseModel):
27
+ """
28
+ Information about a session artifact generated and uploaded.
29
+ """ # noqa: E501
30
+ id: StrictStr
31
+ session_id: StrictStr
32
+ name: StrictStr
33
+ mime_type: StrictStr
34
+ size_bytes: StrictInt
35
+ created_at: Optional[datetime] = None
36
+ __properties: ClassVar[List[str]] = ["id", "session_id", "name", "mime_type", "size_bytes", "created_at"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of ArtifactInfo from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ """
69
+ excluded_fields: Set[str] = set([
70
+ ])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ return _dict
78
+
79
+ @classmethod
80
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
+ """Create an instance of ArtifactInfo from a dict"""
82
+ if obj is None:
83
+ return None
84
+
85
+ if not isinstance(obj, dict):
86
+ return cls.model_validate(obj)
87
+
88
+ _obj = cls.model_validate({
89
+ "id": obj.get("id"),
90
+ "session_id": obj.get("session_id"),
91
+ "name": obj.get("name"),
92
+ "mime_type": obj.get("mime_type"),
93
+ "size_bytes": obj.get("size_bytes"),
94
+ "created_at": obj.get("created_at")
95
+ })
96
+ return _obj
97
+
98
+
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class ErrorResponse(BaseModel):
26
+ """
27
+ Standard error response body.
28
+ """ # noqa: E501
29
+ error: StrictStr = Field(description="Human-readable error message.")
30
+ code: Optional[StrictStr] = Field(default=None, description="Machine-readable error code.")
31
+ details: Optional[Dict[str, Any]] = Field(default=None, description="Additional structured details about the error.")
32
+ __properties: ClassVar[List[str]] = ["error", "code", "details"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of ErrorResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of ErrorResponse from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "error": obj.get("error"),
86
+ "code": obj.get("code"),
87
+ "details": obj.get("details")
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class InvestigateAlertRequest(BaseModel):
26
+ """
27
+ Optional parameters for starting or retrieving an alert investigation.
28
+ """ # noqa: E501
29
+ force_new: Optional[StrictBool] = Field(default=False, description="Force a new investigation to be created.")
30
+ remediation_requested: Optional[StrictBool] = Field(default=False, description="When true, satisfy on_request remediation mode for this run (attempt a HITL-gated fix PR when evidence supports a durable code change). Ignored when remediation mode is off.")
31
+ operator_message: Optional[StrictStr] = Field(default=None, description="Optional operator text for this investigation. When it explicitly asks to open a fix PR or remediate, it satisfies on_request remediation mode the same as remediation_requested.")
32
+ __properties: ClassVar[List[str]] = ["force_new", "remediation_requested", "operator_message"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of InvestigateAlertRequest from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of InvestigateAlertRequest from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "force_new": obj.get("force_new") if obj.get("force_new") is not None else False,
86
+ "remediation_requested": obj.get("remediation_requested") if obj.get("remediation_requested") is not None else False,
87
+ "operator_message": obj.get("operator_message")
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ StackGen External API
5
+
6
+ Allowlisted StackGen API surface for the public SDK. Managed via api-docs/product/allowlists/external.yaml.
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing import Any, ClassVar, Dict, List
22
+ from stackgen.generated.models.investigation_ref import InvestigationRef
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class InvestigateResponse(BaseModel):
27
+ """
28
+ Investigation started or existing investigation returned.
29
+ """ # noqa: E501
30
+ investigation: InvestigationRef
31
+ __properties: ClassVar[List[str]] = ["investigation"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of InvestigateResponse from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # override the default output from pydantic by calling `to_dict()` of investigation
73
+ if self.investigation:
74
+ _dict['investigation'] = self.investigation.to_dict()
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of InvestigateResponse from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({
87
+ "investigation": InvestigationRef.from_dict(obj["investigation"]) if obj.get("investigation") is not None else None
88
+ })
89
+ return _obj
90
+
91
+