@distilled.cloud/namespacelabs 0.0.0 → 1.0.0-rc.21

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 (219) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +130 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +73 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +59 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +44 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/pagination.d.ts +2 -0
  17. package/lib/pagination.d.ts.map +1 -0
  18. package/lib/pagination.js +1 -0
  19. package/lib/protocol.d.ts +19 -0
  20. package/lib/protocol.d.ts.map +1 -0
  21. package/lib/protocol.js +1 -0
  22. package/lib/retry.d.ts +12 -0
  23. package/lib/retry.d.ts.map +1 -0
  24. package/lib/retry.js +1 -0
  25. package/lib/services/buildkite_jobs.d.ts +129 -0
  26. package/lib/services/buildkite_jobs.d.ts.map +1 -0
  27. package/lib/services/buildkite_jobs.js +2 -0
  28. package/lib/services/buildkite_jobs.js.map +1 -0
  29. package/lib/services/buildkite_queue.d.ts +186 -0
  30. package/lib/services/buildkite_queue.d.ts.map +1 -0
  31. package/lib/services/buildkite_queue.js +2 -0
  32. package/lib/services/buildkite_queue.js.map +1 -0
  33. package/lib/services/index.d.ts +3 -0
  34. package/lib/services/index.d.ts.map +1 -0
  35. package/lib/services/index.js +2 -0
  36. package/lib/services.lazy/buildkite_jobs.js +1 -0
  37. package/lib/services.lazy/buildkite_queue.js +1 -0
  38. package/lib/services.lazy/index.js +3 -0
  39. package/lib/traits.d.ts +3 -0
  40. package/lib/traits.d.ts.map +1 -0
  41. package/lib/traits.js +1 -0
  42. package/lib/unstable-services/artifacts.d.ts +268 -0
  43. package/lib/unstable-services/artifacts.d.ts.map +1 -0
  44. package/lib/unstable-services/artifacts.js +2 -0
  45. package/lib/unstable-services/artifacts.js.map +1 -0
  46. package/lib/unstable-services/audit.d.ts +157 -0
  47. package/lib/unstable-services/audit.d.ts.map +1 -0
  48. package/lib/unstable-services/audit.js +2 -0
  49. package/lib/unstable-services/audit.js.map +1 -0
  50. package/lib/unstable-services/bazel.d.ts +181 -0
  51. package/lib/unstable-services/bazel.d.ts.map +1 -0
  52. package/lib/unstable-services/bazel.js +2 -0
  53. package/lib/unstable-services/bazel.js.map +1 -0
  54. package/lib/unstable-services/bazel_cache.d.ts +126 -0
  55. package/lib/unstable-services/bazel_cache.d.ts.map +1 -0
  56. package/lib/unstable-services/bazel_cache.js +2 -0
  57. package/lib/unstable-services/bazel_cache.js.map +1 -0
  58. package/lib/unstable-services/builder.d.ts +242 -0
  59. package/lib/unstable-services/builder.d.ts.map +1 -0
  60. package/lib/unstable-services/builder.js +2 -0
  61. package/lib/unstable-services/builder.js.map +1 -0
  62. package/lib/unstable-services/compute.d.ts +1124 -0
  63. package/lib/unstable-services/compute.d.ts.map +1 -0
  64. package/lib/unstable-services/compute.js +47 -0
  65. package/lib/unstable-services/compute.js.map +1 -0
  66. package/lib/unstable-services/compute_command.d.ts +120 -0
  67. package/lib/unstable-services/compute_command.d.ts.map +1 -0
  68. package/lib/unstable-services/compute_command.js +2 -0
  69. package/lib/unstable-services/compute_command.js.map +1 -0
  70. package/lib/unstable-services/compute_observability.d.ts +165 -0
  71. package/lib/unstable-services/compute_observability.d.ts.map +1 -0
  72. package/lib/unstable-services/compute_observability.js +2 -0
  73. package/lib/unstable-services/compute_observability.js.map +1 -0
  74. package/lib/unstable-services/compute_storage.d.ts +379 -0
  75. package/lib/unstable-services/compute_storage.d.ts.map +1 -0
  76. package/lib/unstable-services/compute_storage.js +33 -0
  77. package/lib/unstable-services/compute_storage.js.map +1 -0
  78. package/lib/unstable-services/compute_usage.d.ts +283 -0
  79. package/lib/unstable-services/compute_usage.d.ts.map +1 -0
  80. package/lib/unstable-services/compute_usage.js +2 -0
  81. package/lib/unstable-services/compute_usage.js.map +1 -0
  82. package/lib/unstable-services/egress.d.ts +191 -0
  83. package/lib/unstable-services/egress.d.ts.map +1 -0
  84. package/lib/unstable-services/egress.js +2 -0
  85. package/lib/unstable-services/egress.js.map +1 -0
  86. package/lib/unstable-services/experimental_compute_reservation.d.ts +672 -0
  87. package/lib/unstable-services/experimental_compute_reservation.d.ts.map +1 -0
  88. package/lib/unstable-services/experimental_compute_reservation.js +23 -0
  89. package/lib/unstable-services/experimental_compute_reservation.js.map +1 -0
  90. package/lib/unstable-services/experimental_remote_results.d.ts +496 -0
  91. package/lib/unstable-services/experimental_remote_results.d.ts.map +1 -0
  92. package/lib/unstable-services/experimental_remote_results.js +2 -0
  93. package/lib/unstable-services/experimental_remote_results.js.map +1 -0
  94. package/lib/unstable-services/github_image.d.ts +162 -0
  95. package/lib/unstable-services/github_image.d.ts.map +1 -0
  96. package/lib/unstable-services/github_image.js +2 -0
  97. package/lib/unstable-services/github_image.js.map +1 -0
  98. package/lib/unstable-services/github_jobs.d.ts +183 -0
  99. package/lib/unstable-services/github_jobs.d.ts.map +1 -0
  100. package/lib/unstable-services/github_jobs.js +2 -0
  101. package/lib/unstable-services/github_jobs.js.map +1 -0
  102. package/lib/unstable-services/github_profile.d.ts +296 -0
  103. package/lib/unstable-services/github_profile.d.ts.map +1 -0
  104. package/lib/unstable-services/github_profile.js +2 -0
  105. package/lib/unstable-services/github_profile.js.map +1 -0
  106. package/lib/unstable-services/gradle_cache.d.ts +125 -0
  107. package/lib/unstable-services/gradle_cache.d.ts.map +1 -0
  108. package/lib/unstable-services/gradle_cache.js +2 -0
  109. package/lib/unstable-services/gradle_cache.js.map +1 -0
  110. package/lib/unstable-services/httpcache.d.ts +125 -0
  111. package/lib/unstable-services/httpcache.d.ts.map +1 -0
  112. package/lib/unstable-services/httpcache.js +2 -0
  113. package/lib/unstable-services/httpcache.js.map +1 -0
  114. package/lib/unstable-services/iam_tenant.d.ts +457 -0
  115. package/lib/unstable-services/iam_tenant.d.ts.map +1 -0
  116. package/lib/unstable-services/iam_tenant.js +45 -0
  117. package/lib/unstable-services/iam_tenant.js.map +1 -0
  118. package/lib/unstable-services/iam_tenant_membership.d.ts +114 -0
  119. package/lib/unstable-services/iam_tenant_membership.d.ts.map +1 -0
  120. package/lib/unstable-services/iam_tenant_membership.js +2 -0
  121. package/lib/unstable-services/iam_tenant_membership.js.map +1 -0
  122. package/lib/unstable-services/iam_token.d.ts +257 -0
  123. package/lib/unstable-services/iam_token.d.ts.map +1 -0
  124. package/lib/unstable-services/iam_token.js +2 -0
  125. package/lib/unstable-services/iam_token.js.map +1 -0
  126. package/lib/unstable-services/image.d.ts +222 -0
  127. package/lib/unstable-services/image.d.ts.map +1 -0
  128. package/lib/unstable-services/image.js +2 -0
  129. package/lib/unstable-services/image.js.map +1 -0
  130. package/lib/unstable-services/index.d.ts +28 -0
  131. package/lib/unstable-services/index.d.ts.map +1 -0
  132. package/lib/unstable-services/index.js +27 -0
  133. package/lib/unstable-services/private_devbox.d.ts +1180 -0
  134. package/lib/unstable-services/private_devbox.d.ts.map +1 -0
  135. package/lib/unstable-services/private_devbox.js +81 -0
  136. package/lib/unstable-services/private_devbox.js.map +1 -0
  137. package/lib/unstable-services/private_user_sessions.d.ts +145 -0
  138. package/lib/unstable-services/private_user_sessions.d.ts.map +1 -0
  139. package/lib/unstable-services/private_user_sessions.js +2 -0
  140. package/lib/unstable-services/private_user_sessions.js.map +1 -0
  141. package/lib/unstable-services/registry.d.ts +373 -0
  142. package/lib/unstable-services/registry.d.ts.map +1 -0
  143. package/lib/unstable-services/registry.js +34 -0
  144. package/lib/unstable-services/registry.js.map +1 -0
  145. package/lib/unstable-services/testing.d.ts +160 -0
  146. package/lib/unstable-services/testing.d.ts.map +1 -0
  147. package/lib/unstable-services/testing.js +2 -0
  148. package/lib/unstable-services/testing.js.map +1 -0
  149. package/lib/unstable-services/vault.d.ts +203 -0
  150. package/lib/unstable-services/vault.d.ts.map +1 -0
  151. package/lib/unstable-services/vault.js +2 -0
  152. package/lib/unstable-services/vault.js.map +1 -0
  153. package/lib/unstable-services.lazy/artifacts.js +1 -0
  154. package/lib/unstable-services.lazy/audit.js +1 -0
  155. package/lib/unstable-services.lazy/bazel.js +1 -0
  156. package/lib/unstable-services.lazy/bazel_cache.js +1 -0
  157. package/lib/unstable-services.lazy/builder.js +1 -0
  158. package/lib/unstable-services.lazy/compute.js +4 -0
  159. package/lib/unstable-services.lazy/compute_command.js +1 -0
  160. package/lib/unstable-services.lazy/compute_observability.js +1 -0
  161. package/lib/unstable-services.lazy/compute_storage.js +4 -0
  162. package/lib/unstable-services.lazy/compute_usage.js +1 -0
  163. package/lib/unstable-services.lazy/egress.js +1 -0
  164. package/lib/unstable-services.lazy/experimental_compute_reservation.js +4 -0
  165. package/lib/unstable-services.lazy/experimental_remote_results.js +1 -0
  166. package/lib/unstable-services.lazy/github_image.js +1 -0
  167. package/lib/unstable-services.lazy/github_jobs.js +1 -0
  168. package/lib/unstable-services.lazy/github_profile.js +1 -0
  169. package/lib/unstable-services.lazy/gradle_cache.js +1 -0
  170. package/lib/unstable-services.lazy/httpcache.js +1 -0
  171. package/lib/unstable-services.lazy/iam_tenant.js +4 -0
  172. package/lib/unstable-services.lazy/iam_tenant_membership.js +1 -0
  173. package/lib/unstable-services.lazy/iam_token.js +1 -0
  174. package/lib/unstable-services.lazy/image.js +1 -0
  175. package/lib/unstable-services.lazy/index.js +3 -0
  176. package/lib/unstable-services.lazy/private_devbox.js +4 -0
  177. package/lib/unstable-services.lazy/private_user_sessions.js +1 -0
  178. package/lib/unstable-services.lazy/registry.js +4 -0
  179. package/lib/unstable-services.lazy/testing.js +1 -0
  180. package/lib/unstable-services.lazy/vault.js +1 -0
  181. package/package.json +89 -2
  182. package/src/credentials.ts +208 -0
  183. package/src/errors.ts +71 -0
  184. package/src/index.ts +50 -0
  185. package/src/pagination.ts +1 -0
  186. package/src/protocol.ts +83 -0
  187. package/src/retry.ts +28 -0
  188. package/src/services/buildkite_jobs.ts +230 -0
  189. package/src/services/buildkite_queue.ts +453 -0
  190. package/src/services/index.ts +3 -0
  191. package/src/traits.ts +36 -0
  192. package/src/unstable-services/artifacts.ts +769 -0
  193. package/src/unstable-services/audit.ts +323 -0
  194. package/src/unstable-services/bazel.ts +423 -0
  195. package/src/unstable-services/bazel_cache.ts +219 -0
  196. package/src/unstable-services/builder.ts +576 -0
  197. package/src/unstable-services/compute.ts +2991 -0
  198. package/src/unstable-services/compute_command.ts +220 -0
  199. package/src/unstable-services/compute_observability.ts +436 -0
  200. package/src/unstable-services/compute_storage.ts +1167 -0
  201. package/src/unstable-services/compute_usage.ts +738 -0
  202. package/src/unstable-services/egress.ts +516 -0
  203. package/src/unstable-services/experimental_compute_reservation.ts +1499 -0
  204. package/src/unstable-services/experimental_remote_results.ts +1165 -0
  205. package/src/unstable-services/github_image.ts +301 -0
  206. package/src/unstable-services/github_jobs.ts +389 -0
  207. package/src/unstable-services/github_profile.ts +729 -0
  208. package/src/unstable-services/gradle_cache.ts +271 -0
  209. package/src/unstable-services/httpcache.ts +271 -0
  210. package/src/unstable-services/iam_tenant.ts +1720 -0
  211. package/src/unstable-services/iam_tenant_membership.ts +253 -0
  212. package/src/unstable-services/iam_token.ts +788 -0
  213. package/src/unstable-services/image.ts +602 -0
  214. package/src/unstable-services/index.ts +28 -0
  215. package/src/unstable-services/private_devbox.ts +4256 -0
  216. package/src/unstable-services/private_user_sessions.ts +410 -0
  217. package/src/unstable-services/registry.ts +1242 -0
  218. package/src/unstable-services/testing.ts +394 -0
  219. package/src/unstable-services/vault.ts +522 -0
@@ -0,0 +1,220 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ import * as C from "@distilled.cloud/core/category";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema-lite";
5
+ import * as __L from "@distilled.cloud/core/schema-lite";
6
+ import { NamespaceLabsServiceErrors } from "../errors.ts";
7
+ import {
8
+ NamespaceLabsProtocol,
9
+ type NamespaceLabsOpError,
10
+ type NamespaceLabsOpContext,
11
+ } from "../protocol.ts";
12
+ import * as Retry from "../retry.ts";
13
+ import * as T from "../traits.ts";
14
+ // Schema table, filled on first reach (see __S at the end).
15
+ const __s: any[] = [];
16
+
17
+ export type { NamespaceLabsOpError, NamespaceLabsOpContext };
18
+
19
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
20
+ const TELEMETRY = {
21
+ system: "namespacelabs-api",
22
+ responseHeaders: [
23
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
24
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
25
+ ],
26
+ prefix: "Namespacelabs",
27
+ service: "CommandService",
28
+ propagate: "w3c",
29
+ } as const;
30
+
31
+ export class AlreadyExists
32
+ extends /*@__PURE__*/ T.applyErrorMatchers(
33
+ /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
34
+ message: S.String,
35
+ body: S.Unknown,
36
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
37
+ }).pipe(C.withConflictError),
38
+ [{ status: 409, body: { "/code": "already_exists" } }],
39
+ ) {}
40
+
41
+ export class FailedPrecondition
42
+ extends /*@__PURE__*/ T.applyErrorMatchers(
43
+ /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
44
+ message: S.String,
45
+ body: S.Unknown,
46
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
47
+ }).pipe(C.withBadRequestError),
48
+ [{ status: 400, body: { "/code": "failed_precondition" } }],
49
+ ) {}
50
+
51
+ export class InvalidArgument
52
+ extends /*@__PURE__*/ T.applyErrorMatchers(
53
+ /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
54
+ message: S.String,
55
+ body: S.Unknown,
56
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
57
+ }).pipe(C.withBadRequestError),
58
+ [{ status: 400, body: { "/code": "invalid_argument" } }],
59
+ ) {}
60
+
61
+ export class NotFound
62
+ extends /*@__PURE__*/ T.applyErrorMatchers(
63
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
64
+ message: S.String,
65
+ body: S.Unknown,
66
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
67
+ }).pipe(C.withBadRequestError),
68
+ [{ status: 404 }],
69
+ ) {}
70
+
71
+ export class PermissionDenied
72
+ extends /*@__PURE__*/ T.applyErrorMatchers(
73
+ /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
74
+ message: S.String,
75
+ body: S.Unknown,
76
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
77
+ }).pipe(C.withAuthError),
78
+ [{ status: 403 }],
79
+ ) {}
80
+
81
+ export class ResourceExhausted
82
+ extends /*@__PURE__*/ T.applyErrorMatchers(
83
+ /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
84
+ message: S.String,
85
+ body: S.Unknown,
86
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
87
+ retryAfter: /*@__PURE__*/ S.optional(S.Duration),
88
+ }).pipe(C.withThrottlingError),
89
+ [{ status: 429 }],
90
+ ) {}
91
+
92
+ export class Unauthenticated
93
+ extends /*@__PURE__*/ T.applyErrorMatchers(
94
+ /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
95
+ message: S.String,
96
+ body: S.Unknown,
97
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
98
+ }).pipe(C.withAuthError),
99
+ [{ status: 401 }],
100
+ ) {}
101
+
102
+ export type StringList = Array<string>;
103
+ export interface EnvironmentVariable {
104
+ /** Required: Name under which the environment variable will be available, e.g. "FOOBAR_VAR_NAME". */
105
+ name?: string | undefined;
106
+ /** Optional: If set, use this static value for the environment variable. */
107
+ value?: string | undefined;
108
+ /** Optional: If set, overrides value. Namespace will dynamically resolve the secret on instance creation. By default, no secrets are resolved unless requested explicitly. */
109
+ fromSecretId?: string | undefined;
110
+ }
111
+ export type EnvironmentVariableList = Array<EnvironmentVariable>;
112
+ export interface Command {
113
+ /** The command to execute, e.g. ["ls", "-la"]. */
114
+ command?: StringList | undefined;
115
+ /** Optional environment variables to set for the command. */
116
+ envVars?: EnvironmentVariableList | undefined;
117
+ /** Optional working directory for the command. */
118
+ cwd?: string | undefined;
119
+ }
120
+ export interface RunCommandSyncRequest {
121
+ /** The ID of instance which this call targets. */
122
+ instanceId?: string | undefined;
123
+ /** The name of the container to run the command in. */
124
+ targetContainerName?: string | undefined;
125
+ /** The command to execute. */
126
+ command?: Command | undefined;
127
+ }
128
+ export interface RunCommandSyncResponse {
129
+ /** The combined stdout output. */
130
+ stdout: string;
131
+ /** The combined stderr output. */
132
+ stderr: string;
133
+ /** The exit code of the command. */
134
+ exitCode: number;
135
+ }
136
+ export type RunCommandSyncError =
137
+ | InvalidArgument
138
+ | FailedPrecondition
139
+ | Unauthenticated
140
+ | PermissionDenied
141
+ | NotFound
142
+ | AlreadyExists
143
+ | ResourceExhausted
144
+ | NamespaceLabsOpError;
145
+ /** Runs a command in a container within a running instance and waits for it to complete. Stdout and stderr are bundled into a single response, similar to CombinedOutput. ### Errors - If the instance does not exist, a `NotFound` status is returned. - If the target container does not exist, a `NotFound` status is returned. */
146
+ export const runCommandSync: API.OperationMethod<
147
+ RunCommandSyncRequest,
148
+ RunCommandSyncResponse,
149
+ RunCommandSyncError,
150
+ NamespaceLabsOpContext
151
+ > = /*@__PURE__*/ API.make(() => ({
152
+ input: __S(4, __c0, 4) as any as S.Schema<RunCommandSyncRequest>,
153
+ output: __S(5, __c0, 5) as any as S.Schema<RunCommandSyncResponse>,
154
+ errors: [
155
+ InvalidArgument,
156
+ FailedPrecondition,
157
+ Unauthenticated,
158
+ PermissionDenied,
159
+ NotFound,
160
+ AlreadyExists,
161
+ ResourceExhausted,
162
+ ],
163
+ serviceErrors: NamespaceLabsServiceErrors,
164
+ protocol: NamespaceLabsProtocol,
165
+ retry: Retry.Retry,
166
+ telemetry: TELEMETRY,
167
+ span: "RunCommandSync",
168
+ }));
169
+
170
+ // Schema builders: each runs one schema initializer, on that schema's first use.
171
+ function __c0(j: number): any {
172
+ switch (j) {
173
+ case 0:
174
+ return S.Array(S.String);
175
+ case 1:
176
+ return S.suspend(() =>
177
+ S.Struct({
178
+ name: S.optional(S.String),
179
+ value: S.optional(S.String),
180
+ fromSecretId: S.optional(S.String),
181
+ }),
182
+ ).annotate({ identifier: "EnvironmentVariable" });
183
+ case 2:
184
+ return S.Array(__S(1, __c0, 1));
185
+ case 3:
186
+ return S.suspend(() =>
187
+ S.Struct({
188
+ command: S.optional(__S(0, __c0, 0)),
189
+ envVars: S.optional(__S(2, __c0, 2)),
190
+ cwd: S.optional(S.String),
191
+ }),
192
+ ).annotate({ identifier: "Command" });
193
+ case 4:
194
+ return S.suspend(() =>
195
+ S.Struct({
196
+ instanceId: S.optional(S.String),
197
+ targetContainerName: S.optional(S.String),
198
+ command: S.optional(__S(3, __c0, 3)),
199
+ }).pipe(
200
+ T.Http({
201
+ method: "POST",
202
+ uri: "/namespace.cloud.compute.v1beta.CommandService/RunCommandSync",
203
+ code: 200,
204
+ }),
205
+ ),
206
+ ).annotate({ identifier: "RunCommandSyncRequest" });
207
+ case 5:
208
+ return S.suspend(() =>
209
+ S.Struct({
210
+ stdout: S.String,
211
+ stderr: S.String,
212
+ exitCode: S.Number,
213
+ }),
214
+ ).annotate({ identifier: "RunCommandSyncResponse" });
215
+ }
216
+ }
217
+ // Schema table: entry i is schema j of builder f, made on first reach.
218
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
219
+ return (__s[i] ??= __L.at(f, j));
220
+ }
@@ -0,0 +1,436 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ import * as C from "@distilled.cloud/core/category";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (buf.build/namespace/cloud -> smithy). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema-lite";
5
+ import * as __L from "@distilled.cloud/core/schema-lite";
6
+ import { NamespaceLabsServiceErrors } from "../errors.ts";
7
+ import { paginateCursor } from "../pagination.ts";
8
+ import {
9
+ NamespaceLabsProtocol,
10
+ type NamespaceLabsOpError,
11
+ type NamespaceLabsOpContext,
12
+ } from "../protocol.ts";
13
+ import * as Retry from "../retry.ts";
14
+ import * as T from "../traits.ts";
15
+ // Schema table, filled on first reach (see __S at the end).
16
+ const __s: any[] = [];
17
+
18
+ export type { NamespaceLabsOpError, NamespaceLabsOpContext };
19
+
20
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
21
+ const TELEMETRY = {
22
+ system: "namespacelabs-api",
23
+ responseHeaders: [
24
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
25
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
26
+ ],
27
+ prefix: "Namespacelabs",
28
+ service: "ObservabilityService",
29
+ propagate: "w3c",
30
+ } as const;
31
+
32
+ export class AlreadyExists
33
+ extends /*@__PURE__*/ T.applyErrorMatchers(
34
+ /*@__PURE__*/ S.TaggedError<AlreadyExists>()("AlreadyExists", {
35
+ message: S.String,
36
+ body: S.Unknown,
37
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
38
+ }).pipe(C.withConflictError),
39
+ [{ status: 409, body: { "/code": "already_exists" } }],
40
+ ) {}
41
+
42
+ export class FailedPrecondition
43
+ extends /*@__PURE__*/ T.applyErrorMatchers(
44
+ /*@__PURE__*/ S.TaggedError<FailedPrecondition>()("FailedPrecondition", {
45
+ message: S.String,
46
+ body: S.Unknown,
47
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
48
+ }).pipe(C.withBadRequestError),
49
+ [{ status: 400, body: { "/code": "failed_precondition" } }],
50
+ ) {}
51
+
52
+ export class InvalidArgument
53
+ extends /*@__PURE__*/ T.applyErrorMatchers(
54
+ /*@__PURE__*/ S.TaggedError<InvalidArgument>()("InvalidArgument", {
55
+ message: S.String,
56
+ body: S.Unknown,
57
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
58
+ }).pipe(C.withBadRequestError),
59
+ [{ status: 400, body: { "/code": "invalid_argument" } }],
60
+ ) {}
61
+
62
+ export class NotFound
63
+ extends /*@__PURE__*/ T.applyErrorMatchers(
64
+ /*@__PURE__*/ S.TaggedError<NotFound>()("NotFound", {
65
+ message: S.String,
66
+ body: S.Unknown,
67
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
68
+ }).pipe(C.withBadRequestError),
69
+ [{ status: 404 }],
70
+ ) {}
71
+
72
+ export class PermissionDenied
73
+ extends /*@__PURE__*/ T.applyErrorMatchers(
74
+ /*@__PURE__*/ S.TaggedError<PermissionDenied>()("PermissionDenied", {
75
+ message: S.String,
76
+ body: S.Unknown,
77
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
78
+ }).pipe(C.withAuthError),
79
+ [{ status: 403 }],
80
+ ) {}
81
+
82
+ export class ResourceExhausted
83
+ extends /*@__PURE__*/ T.applyErrorMatchers(
84
+ /*@__PURE__*/ S.TaggedError<ResourceExhausted>()("ResourceExhausted", {
85
+ message: S.String,
86
+ body: S.Unknown,
87
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
88
+ retryAfter: /*@__PURE__*/ S.optional(S.Duration),
89
+ }).pipe(C.withThrottlingError),
90
+ [{ status: 429 }],
91
+ ) {}
92
+
93
+ export class Unauthenticated
94
+ extends /*@__PURE__*/ T.applyErrorMatchers(
95
+ /*@__PURE__*/ S.TaggedError<Unauthenticated>()("Unauthenticated", {
96
+ message: S.String,
97
+ body: S.Unknown,
98
+ headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)),
99
+ }).pipe(C.withAuthError),
100
+ [{ status: 401 }],
101
+ ) {}
102
+
103
+ export interface FetchInstanceDiagnosticsRequest {
104
+ instanceId?: string | undefined;
105
+ }
106
+ export interface OOMEvent {
107
+ /** When the out-of-memory kill was detected. */
108
+ timestamp?: string | undefined;
109
+ /** Diagnostic information about the process that was killed. */
110
+ message: string;
111
+ }
112
+ export type OOMEventList = Array<OOMEvent>;
113
+ export interface FetchInstanceDiagnosticsResponse {
114
+ outOfMemoryEvents: OOMEventList;
115
+ }
116
+ export interface TimestampRange {
117
+ after?: string | undefined;
118
+ before?: string | undefined;
119
+ }
120
+ export interface FetchInstanceEgressRequest {
121
+ instanceId?: string | undefined;
122
+ /** Optional */
123
+ timestampRange?: TimestampRange | undefined;
124
+ /** default 20_000 */
125
+ limit?: number | undefined;
126
+ paginationCursor?: string | undefined;
127
+ }
128
+ export type EgressAction = "ACTION_UNKNOWN" | "ALLOW" | "DENY" | "ADVISORY_DENY";
129
+ export type StringList = Array<string>;
130
+ export interface EgressRecord {
131
+ timestamp?: string | undefined;
132
+ domain: string;
133
+ /** What rule matcher (if any) lead to the action */
134
+ ruleMatch: string;
135
+ action: EgressAction;
136
+ answerIps: StringList;
137
+ }
138
+ export type EgressRecordList = Array<EgressRecord>;
139
+ export interface FetchInstanceEgressResponse {
140
+ records: EgressRecordList;
141
+ paginationCursor: string;
142
+ }
143
+ export type StringMatcherOperator = "OPERATOR_UNKNOWN" | "IS_ANY_OF" | "IS_NOT";
144
+ export interface StringMatcher {
145
+ values?: StringList | undefined;
146
+ op?: StringMatcherOperator | (string & {}) | undefined;
147
+ }
148
+ export type FetchInstanceLogsRequestDirection =
149
+ | "DIRECTION_UNSPECIFIED"
150
+ | "DIRECTION_FORWARD"
151
+ | "DIRECTION_BACKWARD";
152
+ export interface FetchInstanceLogsRequest {
153
+ paginationCursor?: string | undefined;
154
+ linesPerPage?: number | undefined;
155
+ matchInstanceIds?: StringMatcher | undefined;
156
+ timestampRange?: TimestampRange | undefined;
157
+ matchContainerNames?: StringMatcher | undefined;
158
+ /** Orders log lines by timestamp. A pagination cursor preserves the direction of the first request. */
159
+ direction?: FetchInstanceLogsRequestDirection | (string & {}) | undefined;
160
+ }
161
+ export type StringMap = { [key: string]: string | undefined };
162
+ export interface LogLine {
163
+ timestamp?: string | undefined;
164
+ content: string;
165
+ /** E.g. stdout, stderr */
166
+ stream: string;
167
+ labels: StringMap;
168
+ /** E.g. containers, kubernetes, kmsg. */
169
+ source: string;
170
+ }
171
+ export type LogLineList = Array<LogLine>;
172
+ export interface FetchInstanceLogsResponse {
173
+ paginationCursor: string;
174
+ logLine: LogLineList;
175
+ retentionDays: number;
176
+ }
177
+ export type FetchInstanceDiagnosticsError =
178
+ | InvalidArgument
179
+ | FailedPrecondition
180
+ | Unauthenticated
181
+ | PermissionDenied
182
+ | NotFound
183
+ | AlreadyExists
184
+ | ResourceExhausted
185
+ | NamespaceLabsOpError;
186
+ /** Fetches diagnostic findings for a particular instance. Requires the {"instance/o11y/oom", "list"} permission for the instance. ### Errors - If no instance id is provided, an `InvalidArgument` status is returned. */
187
+ export const fetchInstanceDiagnostics: API.OperationMethod<
188
+ FetchInstanceDiagnosticsRequest,
189
+ FetchInstanceDiagnosticsResponse,
190
+ FetchInstanceDiagnosticsError,
191
+ NamespaceLabsOpContext
192
+ > = /*@__PURE__*/ API.make(() => ({
193
+ input: __S(0, __c0, 0) as any as S.Schema<FetchInstanceDiagnosticsRequest>,
194
+ output: __S(3, __c0, 3) as any as S.Schema<FetchInstanceDiagnosticsResponse>,
195
+ errors: [
196
+ InvalidArgument,
197
+ FailedPrecondition,
198
+ Unauthenticated,
199
+ PermissionDenied,
200
+ NotFound,
201
+ AlreadyExists,
202
+ ResourceExhausted,
203
+ ],
204
+ serviceErrors: NamespaceLabsServiceErrors,
205
+ protocol: NamespaceLabsProtocol,
206
+ retry: Retry.Retry,
207
+ telemetry: TELEMETRY,
208
+ span: "FetchInstanceDiagnostics",
209
+ }));
210
+
211
+ export type FetchInstanceEgressError =
212
+ | InvalidArgument
213
+ | FailedPrecondition
214
+ | Unauthenticated
215
+ | PermissionDenied
216
+ | NotFound
217
+ | AlreadyExists
218
+ | ResourceExhausted
219
+ | NamespaceLabsOpError;
220
+ /** Fetches egress filtering decisions for a particular instance. */
221
+ export const fetchInstanceEgress: API.PaginatedOperationMethod<
222
+ FetchInstanceEgressRequest,
223
+ FetchInstanceEgressResponse,
224
+ FetchInstanceEgressError,
225
+ NamespaceLabsOpContext,
226
+ EgressRecord
227
+ > = /*@__PURE__*/ API.makePaginated(
228
+ () => ({
229
+ input: __S(8, __c1, 0) as any as S.Schema<FetchInstanceEgressRequest>,
230
+ output: __S(11, __c1, 3) as any as S.Schema<FetchInstanceEgressResponse>,
231
+ errors: [
232
+ InvalidArgument,
233
+ FailedPrecondition,
234
+ Unauthenticated,
235
+ PermissionDenied,
236
+ NotFound,
237
+ AlreadyExists,
238
+ ResourceExhausted,
239
+ ],
240
+ serviceErrors: NamespaceLabsServiceErrors,
241
+ protocol: NamespaceLabsProtocol,
242
+ retry: Retry.Retry,
243
+ telemetry: TELEMETRY,
244
+ span: "FetchInstanceEgress",
245
+ pagination: {
246
+ mode: "cursor",
247
+ inputToken: "paginationCursor",
248
+ outputToken: "paginationCursor",
249
+ items: "records",
250
+ pageSize: "limit",
251
+ } as const,
252
+ }),
253
+ paginateCursor,
254
+ ) as any;
255
+
256
+ export type FetchInstanceLogsError =
257
+ | InvalidArgument
258
+ | FailedPrecondition
259
+ | Unauthenticated
260
+ | PermissionDenied
261
+ | NotFound
262
+ | AlreadyExists
263
+ | ResourceExhausted
264
+ | NamespaceLabsOpError;
265
+ /** Fetches logs of a particular instance (or instances). The instances can still be running. A time range is required to use this API. Either the lookups being done have naturally a range, e.g. last 30 minutes, or you should lookup the time that the instances ran and pass those to the API. If no time range is specified, the serving cost might be too high, and the API server may elect to reject the call. */
266
+ export const fetchInstanceLogs: API.PaginatedOperationMethod<
267
+ FetchInstanceLogsRequest,
268
+ FetchInstanceLogsResponse,
269
+ FetchInstanceLogsError,
270
+ NamespaceLabsOpContext,
271
+ LogLine
272
+ > = /*@__PURE__*/ API.makePaginated(
273
+ () => ({
274
+ input: __S(25, __c3, 1) as any as S.Schema<FetchInstanceLogsRequest>,
275
+ output: __S(29, __c3, 5) as any as S.Schema<FetchInstanceLogsResponse>,
276
+ errors: [
277
+ InvalidArgument,
278
+ FailedPrecondition,
279
+ Unauthenticated,
280
+ PermissionDenied,
281
+ NotFound,
282
+ AlreadyExists,
283
+ ResourceExhausted,
284
+ ],
285
+ serviceErrors: NamespaceLabsServiceErrors,
286
+ protocol: NamespaceLabsProtocol,
287
+ retry: Retry.Retry,
288
+ telemetry: TELEMETRY,
289
+ span: "FetchInstanceLogs",
290
+ pagination: {
291
+ mode: "cursor",
292
+ inputToken: "paginationCursor",
293
+ outputToken: "paginationCursor",
294
+ items: "logLine",
295
+ } as const,
296
+ }),
297
+ paginateCursor,
298
+ ) as any;
299
+
300
+ // Schema builders: each runs one schema initializer, on that schema's first use.
301
+ function __c0(j: number): any {
302
+ switch (j) {
303
+ case 0:
304
+ return S.suspend(() =>
305
+ S.Struct({
306
+ instanceId: S.optional(S.String),
307
+ }).pipe(
308
+ T.Http({
309
+ method: "POST",
310
+ uri: "/namespace.cloud.compute.v1beta.ObservabilityService/FetchInstanceDiagnostics",
311
+ code: 200,
312
+ }),
313
+ ),
314
+ ).annotate({ identifier: "FetchInstanceDiagnosticsRequest" });
315
+ case 1:
316
+ return S.suspend(() =>
317
+ S.Struct({
318
+ timestamp: S.optional(S.String),
319
+ message: S.String,
320
+ }),
321
+ ).annotate({ identifier: "OOMEvent" });
322
+ case 2:
323
+ return S.Array(__S(1, __c0, 1));
324
+ case 3:
325
+ return S.suspend(() =>
326
+ S.Struct({
327
+ outOfMemoryEvents: __S(2, __c0, 2),
328
+ }),
329
+ ).annotate({ identifier: "FetchInstanceDiagnosticsResponse" });
330
+ }
331
+ }
332
+ function __c1(j: number): any {
333
+ switch (j) {
334
+ case 0:
335
+ return S.suspend(() =>
336
+ S.Struct({
337
+ instanceId: S.optional(S.String),
338
+ timestampRange: S.optional(__S(16, __c2, 0)),
339
+ limit: S.optional(S.Number),
340
+ paginationCursor: S.optional(S.String),
341
+ }).pipe(
342
+ T.Http({
343
+ method: "POST",
344
+ uri: "/namespace.cloud.compute.v1beta.ObservabilityService/FetchInstanceEgress",
345
+ code: 200,
346
+ }),
347
+ ),
348
+ ).annotate({ identifier: "FetchInstanceEgressRequest" });
349
+ case 1:
350
+ return S.suspend(() =>
351
+ S.Struct({
352
+ timestamp: S.optional(S.String),
353
+ domain: S.String,
354
+ ruleMatch: S.String,
355
+ action: S.String,
356
+ answerIps: __S(17, __c2, 1),
357
+ }),
358
+ ).annotate({ identifier: "EgressRecord" });
359
+ case 2:
360
+ return S.Array(__S(9, __c1, 1));
361
+ case 3:
362
+ return S.suspend(() =>
363
+ S.Struct({
364
+ records: __S(10, __c1, 2),
365
+ paginationCursor: S.String,
366
+ }),
367
+ ).annotate({ identifier: "FetchInstanceEgressResponse" });
368
+ }
369
+ }
370
+ function __c2(j: number): any {
371
+ switch (j) {
372
+ case 0:
373
+ return S.suspend(() =>
374
+ S.Struct({
375
+ after: S.optional(S.String),
376
+ before: S.optional(S.String),
377
+ }),
378
+ ).annotate({ identifier: "TimestampRange" });
379
+ case 1:
380
+ return S.Array(S.String);
381
+ }
382
+ }
383
+ function __c3(j: number): any {
384
+ switch (j) {
385
+ case 0:
386
+ return S.suspend(() =>
387
+ S.Struct({
388
+ values: S.optional(__S(17, __c2, 1)),
389
+ op: S.optional(S.String),
390
+ }),
391
+ ).annotate({ identifier: "StringMatcher" });
392
+ case 1:
393
+ return S.suspend(() =>
394
+ S.Struct({
395
+ paginationCursor: S.optional(S.String),
396
+ linesPerPage: S.optional(S.Number),
397
+ matchInstanceIds: S.optional(__S(24, __c3, 0)),
398
+ timestampRange: S.optional(__S(16, __c2, 0)),
399
+ matchContainerNames: S.optional(__S(24, __c3, 0)),
400
+ direction: S.optional(S.String),
401
+ }).pipe(
402
+ T.Http({
403
+ method: "POST",
404
+ uri: "/namespace.cloud.compute.v1beta.ObservabilityService/FetchInstanceLogs",
405
+ code: 200,
406
+ }),
407
+ ),
408
+ ).annotate({ identifier: "FetchInstanceLogsRequest" });
409
+ case 2:
410
+ return S.Record(S.String, S.String);
411
+ case 3:
412
+ return S.suspend(() =>
413
+ S.Struct({
414
+ timestamp: S.optional(S.String),
415
+ content: S.String,
416
+ stream: S.String,
417
+ labels: __S(26, __c3, 2),
418
+ source: S.String,
419
+ }),
420
+ ).annotate({ identifier: "LogLine" });
421
+ case 4:
422
+ return S.Array(__S(27, __c3, 3));
423
+ case 5:
424
+ return S.suspend(() =>
425
+ S.Struct({
426
+ paginationCursor: S.String,
427
+ logLine: __S(28, __c3, 4),
428
+ retentionDays: S.Number,
429
+ }),
430
+ ).annotate({ identifier: "FetchInstanceLogsResponse" });
431
+ }
432
+ }
433
+ // Schema table: entry i is schema j of builder f, made on first reach.
434
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
435
+ return (__s[i] ??= __L.at(f, j));
436
+ }