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,136 @@
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, StrictBool, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from stackgen.generated.models.schedule_run_status import ScheduleRunStatus
24
+ from stackgen.generated.models.schedule_target_type import ScheduleTargetType
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class WebhookRunDetail(BaseModel):
29
+ """
30
+ WebhookRunDetail
31
+ """ # noqa: E501
32
+ id: Optional[StrictStr] = Field(default=None, description="Unique webhook invocation identifier.")
33
+ webhook_id: Optional[StrictStr] = Field(default=None, description="Webhook configuration that received this invocation.")
34
+ webhook_name: Optional[StrictStr] = Field(default=None, description="Webhook name snapshot at invocation time.")
35
+ target_type: Optional[ScheduleTargetType] = None
36
+ target_name: Optional[StrictStr] = Field(default=None, description="Target agent or workflow name snapshot at invocation time.")
37
+ status: Optional[ScheduleRunStatus] = None
38
+ started_at: Optional[datetime] = Field(default=None, description="Timestamp when the webhook was accepted.")
39
+ finished_at: Optional[datetime] = Field(default=None, description="Timestamp when dispatch completed, if known.")
40
+ duration_ms: Optional[StrictInt] = Field(default=None, description="Dispatch duration in milliseconds when finished_at is present.")
41
+ error: Optional[StrictStr] = Field(default=None, description="Error message if dispatch failed.")
42
+ run_id: Optional[StrictStr] = Field(default=None, description="Downstream Temporal execution run ID, empty until available.")
43
+ trace_id: Optional[StrictStr] = Field(default=None, description="Execution trace identifier used by the subscribe endpoint.")
44
+ session_id: Optional[StrictStr] = Field(default=None, description="Downstream session identifier for the dispatched run. Used to correlate this invocation with execution_agent_summaries and the NATS session stream. Empty until dispatch starts a run. ")
45
+ subscribe_url: Optional[StrictStr] = Field(default=None, description="Relative SSE subscribe URL for the execution trace.")
46
+ client_ip: Optional[StrictStr] = Field(default=None, description="Source IP address observed by the webhook handler.")
47
+ payload_bytes: Optional[StrictInt] = Field(default=None, description="Original serialized payload size in bytes.")
48
+ payload_truncated: Optional[StrictBool] = Field(default=None, description="Whether the stored payload was replaced by a bounded preview.")
49
+ payload_preview: Optional[StrictStr] = Field(default=None, description="Bounded payload preview, populated when payload_truncated is true.")
50
+ payload: Optional[Dict[str, Any]] = Field(default=None, description="Stored JSON request payload, omitted or replaced with preview metadata when truncated.")
51
+ __properties: ClassVar[List[str]] = ["id", "webhook_id", "webhook_name", "target_type", "target_name", "status", "started_at", "finished_at", "duration_ms", "error", "run_id", "trace_id", "session_id", "subscribe_url", "client_ip", "payload_bytes", "payload_truncated", "payload_preview", "payload"]
52
+
53
+ model_config = ConfigDict(
54
+ populate_by_name=True,
55
+ validate_assignment=True,
56
+ protected_namespaces=(),
57
+ )
58
+
59
+
60
+ def to_str(self) -> str:
61
+ """Returns the string representation of the model using alias"""
62
+ return pprint.pformat(self.model_dump(by_alias=True))
63
+
64
+ def to_json(self) -> str:
65
+ """Returns the JSON representation of the model using alias"""
66
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
67
+ return json.dumps(self.to_dict())
68
+
69
+ @classmethod
70
+ def from_json(cls, json_str: str) -> Optional[Self]:
71
+ """Create an instance of WebhookRunDetail from a JSON string"""
72
+ return cls.from_dict(json.loads(json_str))
73
+
74
+ def to_dict(self) -> Dict[str, Any]:
75
+ """Return the dictionary representation of the model using alias.
76
+
77
+ This has the following differences from calling pydantic's
78
+ `self.model_dump(by_alias=True)`:
79
+
80
+ * `None` is only added to the output dict for nullable fields that
81
+ were set at model initialization. Other fields with value `None`
82
+ are ignored.
83
+ """
84
+ excluded_fields: Set[str] = set([
85
+ ])
86
+
87
+ _dict = self.model_dump(
88
+ by_alias=True,
89
+ exclude=excluded_fields,
90
+ exclude_none=True,
91
+ )
92
+ # set to None if finished_at (nullable) is None
93
+ # and model_fields_set contains the field
94
+ if self.finished_at is None and "finished_at" in self.model_fields_set:
95
+ _dict['finished_at'] = None
96
+
97
+ # set to None if payload (nullable) is None
98
+ # and model_fields_set contains the field
99
+ if self.payload is None and "payload" in self.model_fields_set:
100
+ _dict['payload'] = None
101
+
102
+ return _dict
103
+
104
+ @classmethod
105
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
106
+ """Create an instance of WebhookRunDetail from a dict"""
107
+ if obj is None:
108
+ return None
109
+
110
+ if not isinstance(obj, dict):
111
+ return cls.model_validate(obj)
112
+
113
+ _obj = cls.model_validate({
114
+ "id": obj.get("id"),
115
+ "webhook_id": obj.get("webhook_id"),
116
+ "webhook_name": obj.get("webhook_name"),
117
+ "target_type": obj.get("target_type"),
118
+ "target_name": obj.get("target_name"),
119
+ "status": obj.get("status"),
120
+ "started_at": obj.get("started_at"),
121
+ "finished_at": obj.get("finished_at"),
122
+ "duration_ms": obj.get("duration_ms"),
123
+ "error": obj.get("error"),
124
+ "run_id": obj.get("run_id"),
125
+ "trace_id": obj.get("trace_id"),
126
+ "session_id": obj.get("session_id"),
127
+ "subscribe_url": obj.get("subscribe_url"),
128
+ "client_ip": obj.get("client_ip"),
129
+ "payload_bytes": obj.get("payload_bytes"),
130
+ "payload_truncated": obj.get("payload_truncated"),
131
+ "payload_preview": obj.get("payload_preview"),
132
+ "payload": obj.get("payload")
133
+ })
134
+ return _obj
135
+
136
+
@@ -0,0 +1,97 @@
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, StrictInt
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from stackgen.generated.models.webhook_run import WebhookRun
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class WebhookRunListResponse(BaseModel):
27
+ """
28
+ Paginated webhook invocation history.
29
+ """ # noqa: E501
30
+ items: Optional[List[WebhookRun]] = Field(default=None, description="Array of webhook invocation records ordered newest-first.")
31
+ total: Optional[StrictInt] = Field(default=None, description="Total number of matching webhook invocations.")
32
+ __properties: ClassVar[List[str]] = ["items", "total"]
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 WebhookRunListResponse 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
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
74
+ _items = []
75
+ if self.items:
76
+ for _item_items in self.items:
77
+ if _item_items:
78
+ _items.append(_item_items.to_dict())
79
+ _dict['items'] = _items
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of WebhookRunListResponse from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "items": [WebhookRun.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
93
+ "total": obj.get("total")
94
+ })
95
+ return _obj
96
+
97
+
@@ -0,0 +1,258 @@
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
+ import io
16
+ import json
17
+ import re
18
+ import ssl
19
+
20
+ import urllib3
21
+
22
+ from stackgen.generated.exceptions import ApiException, ApiValueError
23
+
24
+ SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
25
+ RESTResponseType = urllib3.HTTPResponse
26
+
27
+
28
+ def is_socks_proxy_url(url):
29
+ if url is None:
30
+ return False
31
+ split_section = url.split("://")
32
+ if len(split_section) < 2:
33
+ return False
34
+ else:
35
+ return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
36
+
37
+
38
+ class RESTResponse(io.IOBase):
39
+
40
+ def __init__(self, resp) -> None:
41
+ self.response = resp
42
+ self.status = resp.status
43
+ self.reason = resp.reason
44
+ self.data = None
45
+
46
+ def read(self):
47
+ if self.data is None:
48
+ self.data = self.response.data
49
+ return self.data
50
+
51
+ def getheaders(self):
52
+ """Returns a dictionary of the response headers."""
53
+ return self.response.headers
54
+
55
+ def getheader(self, name, default=None):
56
+ """Returns a given response header."""
57
+ return self.response.headers.get(name, default)
58
+
59
+
60
+ class RESTClientObject:
61
+
62
+ def __init__(self, configuration) -> None:
63
+ # urllib3.PoolManager will pass all kw parameters to connectionpool
64
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
65
+ # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
66
+ # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
67
+
68
+ # cert_reqs
69
+ if configuration.verify_ssl:
70
+ cert_reqs = ssl.CERT_REQUIRED
71
+ else:
72
+ cert_reqs = ssl.CERT_NONE
73
+
74
+ pool_args = {
75
+ "cert_reqs": cert_reqs,
76
+ "ca_certs": configuration.ssl_ca_cert,
77
+ "cert_file": configuration.cert_file,
78
+ "key_file": configuration.key_file,
79
+ "ca_cert_data": configuration.ca_cert_data,
80
+ }
81
+ if configuration.assert_hostname is not None:
82
+ pool_args['assert_hostname'] = (
83
+ configuration.assert_hostname
84
+ )
85
+
86
+ if configuration.retries is not None:
87
+ pool_args['retries'] = configuration.retries
88
+
89
+ if configuration.tls_server_name:
90
+ pool_args['server_hostname'] = configuration.tls_server_name
91
+
92
+
93
+ if configuration.socket_options is not None:
94
+ pool_args['socket_options'] = configuration.socket_options
95
+
96
+ if configuration.connection_pool_maxsize is not None:
97
+ pool_args['maxsize'] = configuration.connection_pool_maxsize
98
+
99
+ # https pool manager
100
+ self.pool_manager: urllib3.PoolManager
101
+
102
+ if configuration.proxy:
103
+ if is_socks_proxy_url(configuration.proxy):
104
+ from urllib3.contrib.socks import SOCKSProxyManager
105
+ pool_args["proxy_url"] = configuration.proxy
106
+ pool_args["headers"] = configuration.proxy_headers
107
+ self.pool_manager = SOCKSProxyManager(**pool_args)
108
+ else:
109
+ pool_args["proxy_url"] = configuration.proxy
110
+ pool_args["proxy_headers"] = configuration.proxy_headers
111
+ self.pool_manager = urllib3.ProxyManager(**pool_args)
112
+ else:
113
+ self.pool_manager = urllib3.PoolManager(**pool_args)
114
+
115
+ def request(
116
+ self,
117
+ method,
118
+ url,
119
+ headers=None,
120
+ body=None,
121
+ post_params=None,
122
+ _request_timeout=None
123
+ ):
124
+ """Perform requests.
125
+
126
+ :param method: http request method
127
+ :param url: http request url
128
+ :param headers: http request headers
129
+ :param body: request json body, for `application/json`
130
+ :param post_params: request post parameters,
131
+ `application/x-www-form-urlencoded`
132
+ and `multipart/form-data`
133
+ :param _request_timeout: timeout setting for this request. If one
134
+ number provided, it will be total request
135
+ timeout. It can also be a pair (tuple) of
136
+ (connection, read) timeouts.
137
+ """
138
+ method = method.upper()
139
+ assert method in [
140
+ 'GET',
141
+ 'HEAD',
142
+ 'DELETE',
143
+ 'POST',
144
+ 'PUT',
145
+ 'PATCH',
146
+ 'OPTIONS'
147
+ ]
148
+
149
+ if post_params and body:
150
+ raise ApiValueError(
151
+ "body parameter cannot be used with post_params parameter."
152
+ )
153
+
154
+ post_params = post_params or {}
155
+ headers = headers or {}
156
+
157
+ timeout = None
158
+ if _request_timeout:
159
+ if isinstance(_request_timeout, (int, float)):
160
+ timeout = urllib3.Timeout(total=_request_timeout)
161
+ elif (
162
+ isinstance(_request_timeout, tuple)
163
+ and len(_request_timeout) == 2
164
+ ):
165
+ timeout = urllib3.Timeout(
166
+ connect=_request_timeout[0],
167
+ read=_request_timeout[1]
168
+ )
169
+
170
+ try:
171
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
172
+ if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
173
+
174
+ # no content type provided or payload is json
175
+ content_type = headers.get('Content-Type')
176
+ if (
177
+ not content_type
178
+ or re.search('json', content_type, re.IGNORECASE)
179
+ ):
180
+ request_body = None
181
+ if body is not None:
182
+ request_body = json.dumps(body)
183
+ r = self.pool_manager.request(
184
+ method,
185
+ url,
186
+ body=request_body,
187
+ timeout=timeout,
188
+ headers=headers,
189
+ preload_content=False
190
+ )
191
+ elif content_type == 'application/x-www-form-urlencoded':
192
+ r = self.pool_manager.request(
193
+ method,
194
+ url,
195
+ fields=post_params,
196
+ encode_multipart=False,
197
+ timeout=timeout,
198
+ headers=headers,
199
+ preload_content=False
200
+ )
201
+ elif content_type == 'multipart/form-data':
202
+ # must del headers['Content-Type'], or the correct
203
+ # Content-Type which generated by urllib3 will be
204
+ # overwritten.
205
+ del headers['Content-Type']
206
+ # Ensures that dict objects are serialized
207
+ post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params]
208
+ r = self.pool_manager.request(
209
+ method,
210
+ url,
211
+ fields=post_params,
212
+ encode_multipart=True,
213
+ timeout=timeout,
214
+ headers=headers,
215
+ preload_content=False
216
+ )
217
+ # Pass a `string` parameter directly in the body to support
218
+ # other content types than JSON when `body` argument is
219
+ # provided in serialized form.
220
+ elif isinstance(body, str) or isinstance(body, bytes):
221
+ r = self.pool_manager.request(
222
+ method,
223
+ url,
224
+ body=body,
225
+ timeout=timeout,
226
+ headers=headers,
227
+ preload_content=False
228
+ )
229
+ elif headers['Content-Type'].startswith('text/') and isinstance(body, bool):
230
+ request_body = "true" if body else "false"
231
+ r = self.pool_manager.request(
232
+ method,
233
+ url,
234
+ body=request_body,
235
+ preload_content=False,
236
+ timeout=timeout,
237
+ headers=headers)
238
+ else:
239
+ # Cannot generate the request from given parameters
240
+ msg = """Cannot prepare a request message for provided
241
+ arguments. Please check that your arguments match
242
+ declared content type."""
243
+ raise ApiException(status=0, reason=msg)
244
+ # For `GET`, `HEAD`
245
+ else:
246
+ r = self.pool_manager.request(
247
+ method,
248
+ url,
249
+ fields={},
250
+ timeout=timeout,
251
+ headers=headers,
252
+ preload_content=False
253
+ )
254
+ except urllib3.exceptions.SSLError as e:
255
+ msg = "\n".join([type(e).__name__, str(e)])
256
+ raise ApiException(status=0, reason=msg)
257
+
258
+ return RESTResponse(r)
@@ -0,0 +1,5 @@
1
+ """SRE app namespace."""
2
+
3
+ from stackgen.sre.namespace import SRENamespace
4
+
5
+ __all__ = ["SRENamespace"]
@@ -0,0 +1,57 @@
1
+ """SRE namespace — alerts and investigations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import urllib.parse
7
+ from typing import Any
8
+
9
+ from stackgen import _http
10
+ from stackgen.config import StackgenConfig
11
+
12
+
13
+ def query_string(params: dict[str, Any]) -> str:
14
+ """Build a query string from optional kwargs (omit None values)."""
15
+ cleaned = {k: v for k, v in params.items() if v is not None}
16
+ if not cleaned:
17
+ return ""
18
+ return "?" + urllib.parse.urlencode(cleaned)
19
+
20
+
21
+ class SRENamespace:
22
+ """SRE alerts and investigations."""
23
+
24
+ def __init__(self, config: StackgenConfig) -> None:
25
+ self._config = config
26
+
27
+ def list_alerts(self, **params: Any) -> Any:
28
+ """GET /app/sre/api/v1/alerts"""
29
+ url = f"{self._config.sre_url()}/api/v1/alerts{query_string(params)}"
30
+ return _http.request(url, self._config.api_token)
31
+
32
+ def get_alert(self, alert_id: str) -> Any:
33
+ """GET /app/sre/api/v1/alerts/{id} (operationId getAlertV1)."""
34
+ url = f"{self._config.sre_url()}/api/v1/alerts/{alert_id}"
35
+ return _http.request(url, self._config.api_token)
36
+
37
+ def investigate_alert(self, alert_id: str, body: dict[str, Any] | None = None) -> Any:
38
+ """POST /app/sre/api/v1/alerts/{id}/investigate"""
39
+ url = f"{self._config.sre_url()}/api/v1/alerts/{alert_id}/investigate"
40
+ payload = json.dumps(body or {}).encode("utf-8")
41
+ return _http.request(
42
+ url,
43
+ self._config.api_token,
44
+ method="POST",
45
+ body=payload,
46
+ content_type="application/json",
47
+ )
48
+
49
+ def list_investigations(self, **params: Any) -> Any:
50
+ """GET /app/sre/api/v1/investigations"""
51
+ url = f"{self._config.sre_url()}/api/v1/investigations{query_string(params)}"
52
+ return _http.request(url, self._config.api_token)
53
+
54
+ def get_investigation(self, investigation_id: str) -> Any:
55
+ """GET /app/sre/api/v1/investigations/{id}"""
56
+ url = f"{self._config.sre_url()}/api/v1/investigations/{investigation_id}"
57
+ return _http.request(url, self._config.api_token)
@@ -0,0 +1,5 @@
1
+ """Vault namespace (opt-in via allowlist; empty in v0.1)."""
2
+
3
+ from stackgen.vault.namespace import VaultNamespace
4
+
5
+ __all__ = ["VaultNamespace"]
@@ -0,0 +1,17 @@
1
+ """Vault namespace — secrets (allowlisted separately)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from stackgen.config import StackgenConfig
6
+ from stackgen.errors import NotAllowlistedError
7
+
8
+
9
+ class VaultNamespace:
10
+ """Vault secrets. Operations are allowlisted separately; v0.1 ships none."""
11
+
12
+ def __init__(self, config: StackgenConfig) -> None:
13
+ self._config = config
14
+
15
+ def get_secret(self, secret_id: str) -> None:
16
+ _ = secret_id
17
+ raise NotAllowlistedError("vault", "get_secret")
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.5
2
+ Name: stackgen-sdk
3
+ Version: 0.1.1
4
+ Summary: StackGen SDK — Aiden, SRE, and Vault from one client
5
+ Project-URL: Homepage, https://github.com/appcd-dev/stackgen-sdk
6
+ Project-URL: Documentation, https://github.com/appcd-dev/stackgen-sdk/tree/main/docs
7
+ Project-URL: Repository, https://github.com/appcd-dev/stackgen-sdk
8
+ Project-URL: Issues, https://github.com/appcd-dev/stackgen-sdk/issues
9
+ Author: StackGen
10
+ License-Expression: Apache-2.0
11
+ Keywords: aiden,openapi,sre,stackgen
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: pydantic>=2.0
14
+ Requires-Dist: python-dateutil>=2.8
15
+ Requires-Dist: typing-extensions>=4.0
16
+ Requires-Dist: urllib3>=2.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: build>=1.2; extra == 'dev'
19
+ Requires-Dist: pytest>=8.0; extra == 'dev'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # StackGen Python SDK
23
+
24
+ Install (PyPI):
25
+
26
+ ```bash
27
+ pip install stackgen-sdk==0.1.1
28
+ ```
29
+
30
+ Developers with private repo access:
31
+
32
+ ```bash
33
+ pip install "git+ssh://git@github.com/appcd-dev/stackgen-sdk.git@v0.1.1#subdirectory=clients/python"
34
+ ```
35
+
36
+ Quick start:
37
+
38
+ ```python
39
+ from stackgen import StackgenClient
40
+
41
+ client = StackgenClient.from_env()
42
+ result = client.aiden.run_webhook_and_download_report(open("alert.json").read())
43
+ print(result.session_id, result.output_path)
44
+
45
+ alerts = client.sre.list_alerts()
46
+ ```
47
+
48
+ Environment:
49
+
50
+ | Variable | Purpose |
51
+ |----------|---------|
52
+ | `STACKGEN_URL` | Mothership URL (no `/guild`) |
53
+ | `STACKGEN_TOKEN` | API token (`stackgen_…`) |
54
+ | `WEBHOOK_TOKEN` | Webhook token (`sg_aios_…`) for triggers |
55
+ | `ORG_ID` | Organization UUID |
56
+ | `WEBHOOK_ID` | Optional; older trigger 202 bodies |
57
+
58
+ See [docs/PRODUCT.md](../../docs/PRODUCT.md), [docs/python/IMPLEMENTATION.md](../../docs/python/IMPLEMENTATION.md), and [docs/PUBLISH.md](../../docs/PUBLISH.md).
59
+
60
+ Generated OpenAPI client code lives under `stackgen.generated` (unstable; prefer `StackgenClient`).