@distilled.cloud/clickhouse-cloud 0.0.0 → 1.0.0-rc.22

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 (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +134 -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 +34 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +58 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +49 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/pagination.d.ts +10 -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 +35 -0
  23. package/lib/retry.d.ts.map +1 -0
  24. package/lib/retry.js +1 -0
  25. package/lib/services/api_keys.d.ts +175 -0
  26. package/lib/services/api_keys.d.ts.map +1 -0
  27. package/lib/services/api_keys.js +2 -0
  28. package/lib/services/api_keys.js.map +1 -0
  29. package/lib/services/backup.d.ts +117 -0
  30. package/lib/services/backup.d.ts.map +1 -0
  31. package/lib/services/backup.js +2 -0
  32. package/lib/services/backup.js.map +1 -0
  33. package/lib/services/billing.d.ts +69 -0
  34. package/lib/services/billing.d.ts.map +1 -0
  35. package/lib/services/billing.js +2 -0
  36. package/lib/services/billing.js.map +1 -0
  37. package/lib/services/click_pipes.d.ts +1637 -0
  38. package/lib/services/click_pipes.d.ts.map +1 -0
  39. package/lib/services/click_pipes.js +31 -0
  40. package/lib/services/click_pipes.js.map +1 -0
  41. package/lib/services/index.d.ts +14 -0
  42. package/lib/services/index.d.ts.map +1 -0
  43. package/lib/services/index.js +13 -0
  44. package/lib/services/organization.d.ts +336 -0
  45. package/lib/services/organization.d.ts.map +1 -0
  46. package/lib/services/organization.js +2 -0
  47. package/lib/services/organization.js.map +1 -0
  48. package/lib/services/postgres.d.ts +726 -0
  49. package/lib/services/postgres.d.ts.map +1 -0
  50. package/lib/services/postgres.js +31 -0
  51. package/lib/services/postgres.js.map +1 -0
  52. package/lib/services/prometheus.d.ts +71 -0
  53. package/lib/services/prometheus.d.ts.map +1 -0
  54. package/lib/services/prometheus.js +2 -0
  55. package/lib/services/prometheus.js.map +1 -0
  56. package/lib/services/query_api_endpoints.d.ts +189 -0
  57. package/lib/services/query_api_endpoints.d.ts.map +1 -0
  58. package/lib/services/query_api_endpoints.js +2 -0
  59. package/lib/services/query_api_endpoints.js.map +1 -0
  60. package/lib/services/role_management.d.ts +159 -0
  61. package/lib/services/role_management.d.ts.map +1 -0
  62. package/lib/services/role_management.js +2 -0
  63. package/lib/services/role_management.js.map +1 -0
  64. package/lib/services/saved_queries.d.ts +129 -0
  65. package/lib/services/saved_queries.d.ts.map +1 -0
  66. package/lib/services/saved_queries.js +2 -0
  67. package/lib/services/saved_queries.js.map +1 -0
  68. package/lib/services/service.d.ts +886 -0
  69. package/lib/services/service.d.ts.map +1 -0
  70. package/lib/services/service.js +41 -0
  71. package/lib/services/service.js.map +1 -0
  72. package/lib/services/udf.d.ts +373 -0
  73. package/lib/services/udf.d.ts.map +1 -0
  74. package/lib/services/udf.js +24 -0
  75. package/lib/services/udf.js.map +1 -0
  76. package/lib/services/user_management.d.ts +150 -0
  77. package/lib/services/user_management.d.ts.map +1 -0
  78. package/lib/services/user_management.js +2 -0
  79. package/lib/services/user_management.js.map +1 -0
  80. package/lib/services.lazy/api_keys.js +1 -0
  81. package/lib/services.lazy/backup.js +1 -0
  82. package/lib/services.lazy/billing.js +1 -0
  83. package/lib/services.lazy/click_pipes.js +3 -0
  84. package/lib/services.lazy/index.js +3 -0
  85. package/lib/services.lazy/organization.js +1 -0
  86. package/lib/services.lazy/postgres.js +4 -0
  87. package/lib/services.lazy/prometheus.js +1 -0
  88. package/lib/services.lazy/query_api_endpoints.js +1 -0
  89. package/lib/services.lazy/role_management.js +1 -0
  90. package/lib/services.lazy/saved_queries.js +1 -0
  91. package/lib/services.lazy/service.js +4 -0
  92. package/lib/services.lazy/udf.js +3 -0
  93. package/lib/services.lazy/user_management.js +1 -0
  94. package/lib/traits.d.ts +11 -0
  95. package/lib/traits.d.ts.map +1 -0
  96. package/lib/traits.js +1 -0
  97. package/lib/unstable-services/backup.d.ts +165 -0
  98. package/lib/unstable-services/backup.d.ts.map +1 -0
  99. package/lib/unstable-services/backup.js +2 -0
  100. package/lib/unstable-services/backup.js.map +1 -0
  101. package/lib/unstable-services/billing.d.ts +84 -0
  102. package/lib/unstable-services/billing.d.ts.map +1 -0
  103. package/lib/unstable-services/billing.js +2 -0
  104. package/lib/unstable-services/billing.js.map +1 -0
  105. package/lib/unstable-services/click_pipes.d.ts +324 -0
  106. package/lib/unstable-services/click_pipes.d.ts.map +1 -0
  107. package/lib/unstable-services/click_pipes.js +2 -0
  108. package/lib/unstable-services/click_pipes.js.map +1 -0
  109. package/lib/unstable-services/click_stack.d.ts +3538 -0
  110. package/lib/unstable-services/click_stack.d.ts.map +1 -0
  111. package/lib/unstable-services/click_stack.js +60 -0
  112. package/lib/unstable-services/click_stack.js.map +1 -0
  113. package/lib/unstable-services/index.d.ts +11 -0
  114. package/lib/unstable-services/index.d.ts.map +1 -0
  115. package/lib/unstable-services/index.js +10 -0
  116. package/lib/unstable-services/notifications.d.ts +166 -0
  117. package/lib/unstable-services/notifications.d.ts.map +1 -0
  118. package/lib/unstable-services/notifications.js +2 -0
  119. package/lib/unstable-services/notifications.js.map +1 -0
  120. package/lib/unstable-services/organization.d.ts +403 -0
  121. package/lib/unstable-services/organization.d.ts.map +1 -0
  122. package/lib/unstable-services/organization.js +26 -0
  123. package/lib/unstable-services/organization.js.map +1 -0
  124. package/lib/unstable-services/postgres.d.ts +415 -0
  125. package/lib/unstable-services/postgres.d.ts.map +1 -0
  126. package/lib/unstable-services/postgres.js +2 -0
  127. package/lib/unstable-services/postgres.js.map +1 -0
  128. package/lib/unstable-services/service.d.ts +244 -0
  129. package/lib/unstable-services/service.d.ts.map +1 -0
  130. package/lib/unstable-services/service.js +2 -0
  131. package/lib/unstable-services/service.js.map +1 -0
  132. package/lib/unstable-services/snapshot.d.ts +146 -0
  133. package/lib/unstable-services/snapshot.d.ts.map +1 -0
  134. package/lib/unstable-services/snapshot.js +2 -0
  135. package/lib/unstable-services/snapshot.js.map +1 -0
  136. package/lib/unstable-services/user_management.d.ts +41 -0
  137. package/lib/unstable-services/user_management.d.ts.map +1 -0
  138. package/lib/unstable-services/user_management.js +2 -0
  139. package/lib/unstable-services/user_management.js.map +1 -0
  140. package/lib/unstable-services.lazy/backup.js +1 -0
  141. package/lib/unstable-services.lazy/billing.js +1 -0
  142. package/lib/unstable-services.lazy/click_pipes.js +1 -0
  143. package/lib/unstable-services.lazy/click_stack.js +4 -0
  144. package/lib/unstable-services.lazy/index.js +3 -0
  145. package/lib/unstable-services.lazy/notifications.js +1 -0
  146. package/lib/unstable-services.lazy/organization.js +4 -0
  147. package/lib/unstable-services.lazy/postgres.js +1 -0
  148. package/lib/unstable-services.lazy/service.js +1 -0
  149. package/lib/unstable-services.lazy/snapshot.js +1 -0
  150. package/lib/unstable-services.lazy/user_management.js +1 -0
  151. package/package.json +89 -2
  152. package/src/credentials.ts +88 -0
  153. package/src/errors.ts +76 -0
  154. package/src/index.ts +53 -0
  155. package/src/pagination.ts +9 -0
  156. package/src/protocol.ts +76 -0
  157. package/src/retry.ts +53 -0
  158. package/src/services/api_keys.ts +466 -0
  159. package/src/services/backup.ts +347 -0
  160. package/src/services/billing.ts +170 -0
  161. package/src/services/click_pipes.ts +3483 -0
  162. package/src/services/index.ts +14 -0
  163. package/src/services/organization.ts +901 -0
  164. package/src/services/postgres.ts +1967 -0
  165. package/src/services/prometheus.ts +271 -0
  166. package/src/services/query_api_endpoints.ts +466 -0
  167. package/src/services/role_management.ts +436 -0
  168. package/src/services/saved_queries.ts +384 -0
  169. package/src/services/service.ts +2112 -0
  170. package/src/services/udf.ts +1019 -0
  171. package/src/services/user_management.ts +508 -0
  172. package/src/traits.ts +45 -0
  173. package/src/unstable-services/backup.ts +422 -0
  174. package/src/unstable-services/billing.ts +232 -0
  175. package/src/unstable-services/click_pipes.ts +702 -0
  176. package/src/unstable-services/click_stack.ts +7114 -0
  177. package/src/unstable-services/index.ts +11 -0
  178. package/src/unstable-services/notifications.ts +451 -0
  179. package/src/unstable-services/organization.ts +1107 -0
  180. package/src/unstable-services/postgres.ts +1061 -0
  181. package/src/unstable-services/service.ts +795 -0
  182. package/src/unstable-services/snapshot.ts +397 -0
  183. package/src/unstable-services/user_management.ts +127 -0
@@ -0,0 +1,422 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-clickhouse-cloud/specs/openapi.json). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import type * as Redacted from "effect/Redacted";
6
+ import { ClickHouseCloudServiceErrors } from "../errors.ts";
7
+ import {
8
+ ClickHouseCloudProtocol,
9
+ type ClickHouseCloudOpError,
10
+ type ClickHouseCloudOpContext,
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 { ClickHouseCloudOpError, ClickHouseCloudOpContext };
18
+
19
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
20
+ const TELEMETRY = {
21
+ system: "clickhouse-cloud-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: "ClickhouseCloud",
27
+ service: "Backups",
28
+ labels: "clickhouse_cloud",
29
+ propagate: "w3c",
30
+ } as const;
31
+
32
+ /** Bucket provider */
33
+ export type AwsBackupBucketPostRequestV1BucketProvider = "AWS";
34
+ export interface AwsBackupBucketPostRequestV1 {
35
+ /** Bucket provider */
36
+ bucketProvider?: AwsBackupBucketPostRequestV1BucketProvider | (string & {}) | undefined;
37
+ /** Bucket path */
38
+ bucketPath?: string | undefined;
39
+ /** AWS Role ARN */
40
+ iamRoleArn?: string | undefined;
41
+ /** AWS Role session name */
42
+ iamRoleSessionName?: string | undefined;
43
+ /** External ID the IAM role trust policy requires when the data plane assumes the role */
44
+ iamRoleExternalId?: string | undefined;
45
+ }
46
+ /** Bucket provider */
47
+ export type GcpBackupBucketPostRequestV1BucketProvider = "GCP";
48
+ export interface GcpBackupBucketPostRequestV1 {
49
+ /** Bucket provider */
50
+ bucketProvider?: GcpBackupBucketPostRequestV1BucketProvider | (string & {}) | undefined;
51
+ /** Bucket path */
52
+ bucketPath?: string | undefined;
53
+ /** Access Key ID (HMAC key) */
54
+ accessKeyId?: string | undefined;
55
+ /** Secret Access Key (HMAC secret key) */
56
+ secretAccessKey?: string | Redacted.Redacted<string> | undefined;
57
+ }
58
+ /** Bucket provider */
59
+ export type AzureBackupBucketPostRequestV1BucketProvider = "AZURE";
60
+ export interface AzureBackupBucketPostRequestV1 {
61
+ /** Bucket provider */
62
+ bucketProvider?: AzureBackupBucketPostRequestV1BucketProvider | (string & {}) | undefined;
63
+ /** Container Name */
64
+ containerName?: string | undefined;
65
+ /** Connection String */
66
+ connectionString?: string | Redacted.Redacted<string> | undefined;
67
+ }
68
+ export type BackupBucketPostRequest =
69
+ | AwsBackupBucketPostRequestV1
70
+ | GcpBackupBucketPostRequestV1
71
+ | AzureBackupBucketPostRequestV1;
72
+ export interface CreateBackupBucketRequest {
73
+ /** ID of the requested organization. */
74
+ organizationId: string;
75
+ /** ID of the requested service. */
76
+ serviceId: string;
77
+ body?: BackupBucketPostRequest | undefined;
78
+ }
79
+ /** Bucket provider */
80
+ export type AwsBackupBucketBucketProvider = "AWS";
81
+ export interface AwsBackupBucket {
82
+ /** Unique backup bucket ID */
83
+ id?: string | undefined;
84
+ /** Bucket provider */
85
+ bucketProvider?: AwsBackupBucketBucketProvider | undefined;
86
+ /** Bucket path */
87
+ bucketPath?: string | undefined;
88
+ /** AWS Role ARN */
89
+ iamRoleArn?: string | undefined;
90
+ /** AWS Role session name */
91
+ iamRoleSessionName?: string | undefined;
92
+ /** External ID the IAM role trust policy requires when the data plane assumes the role */
93
+ iamRoleExternalId?: string | undefined;
94
+ }
95
+ /** Bucket provider */
96
+ export type GcpBackupBucketBucketProvider = "GCP";
97
+ export interface GcpBackupBucket {
98
+ /** Unique backup bucket ID */
99
+ id?: string | undefined;
100
+ /** Bucket provider */
101
+ bucketProvider?: GcpBackupBucketBucketProvider | undefined;
102
+ /** Bucket path */
103
+ bucketPath?: string | undefined;
104
+ /** Access Key ID (HMAC key) */
105
+ accessKeyId?: string | undefined;
106
+ }
107
+ /** Bucket provider */
108
+ export type AzureBackupBucketBucketProvider = "AZURE";
109
+ export interface AzureBackupBucket {
110
+ /** Unique backup bucket ID. */
111
+ id?: string | undefined;
112
+ /** Bucket provider */
113
+ bucketProvider?: AzureBackupBucketBucketProvider | undefined;
114
+ /** Container Name */
115
+ containerName?: string | undefined;
116
+ }
117
+ export type BackupBucket = AwsBackupBucket | GcpBackupBucket | AzureBackupBucket;
118
+ export type CreateBackupBucketResponse = BackupBucket;
119
+ export interface DeleteBackupBucketRequest {
120
+ /** ID of the requested organization. */
121
+ organizationId: string;
122
+ /** ID of the requested service. */
123
+ serviceId: string;
124
+ }
125
+ export interface DeleteBackupBucketResponse {
126
+ /** HTTP status code. */
127
+ status?: number | undefined;
128
+ /** Unique id assigned to every request. UUIDv4 */
129
+ requestId?: string | undefined;
130
+ }
131
+ export interface GetBackupBucketRequest {
132
+ /** ID of the organization that owns the service. */
133
+ organizationId: string;
134
+ /** ID of the service. */
135
+ serviceId: string;
136
+ }
137
+ export type GetBackupBucketResponse = BackupBucket;
138
+ /** Bucket provider */
139
+ export type AwsBackupBucketPatchRequestV1BucketProvider = "AWS";
140
+ export interface AwsBackupBucketPatchRequestV1 {
141
+ /** Bucket provider */
142
+ bucketProvider?: AwsBackupBucketPatchRequestV1BucketProvider | (string & {}) | undefined;
143
+ /** Bucket path */
144
+ bucketPath?: string | undefined;
145
+ /** AWS Role ARN */
146
+ iamRoleArn?: string | undefined;
147
+ /** AWS IAM Role session name */
148
+ iamRoleSessionName?: string | null | undefined;
149
+ /** External ID the IAM role trust policy requires when the data plane assumes the role. Set to `null` to clear it. */
150
+ iamRoleExternalId?: string | null | undefined;
151
+ }
152
+ /** Bucket provider */
153
+ export type GcpBackupBucketPatchRequestV1BucketProvider = "GCP";
154
+ export interface GcpBackupBucketPatchRequestV1 {
155
+ /** Bucket provider */
156
+ bucketProvider?: GcpBackupBucketPatchRequestV1BucketProvider | (string & {}) | undefined;
157
+ /** Bucket path */
158
+ bucketPath?: string | undefined;
159
+ /** Access Key ID (HMAC key) */
160
+ accessKeyId?: string | undefined;
161
+ /** Secret Access Key (HMAC secret key) */
162
+ secretAccessKey?: string | Redacted.Redacted<string> | undefined;
163
+ }
164
+ /** Bucket provider */
165
+ export type AzureBackupBucketPatchRequestV1BucketProvider = "AZURE";
166
+ export interface AzureBackupBucketPatchRequestV1 {
167
+ /** Bucket provider */
168
+ bucketProvider?: AzureBackupBucketPatchRequestV1BucketProvider | (string & {}) | undefined;
169
+ /** Container Name */
170
+ containerName?: string | undefined;
171
+ /** Connection String */
172
+ connectionString?: string | Redacted.Redacted<string> | undefined;
173
+ }
174
+ export type BackupBucketPatchRequest =
175
+ | AwsBackupBucketPatchRequestV1
176
+ | GcpBackupBucketPatchRequestV1
177
+ | AzureBackupBucketPatchRequestV1;
178
+ export interface UpdateBackupBucketRequest {
179
+ /** ID of the requested organization. */
180
+ organizationId: string;
181
+ /** ID of the requested service. */
182
+ serviceId: string;
183
+ body?: BackupBucketPatchRequest | undefined;
184
+ }
185
+ export type UpdateBackupBucketResponse = BackupBucket;
186
+ export type CreateBackupBucketError = ClickHouseCloudOpError;
187
+ /** Create service backup bucket **This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. <br /><br /> Create service backup bucket. Requires ADMIN auth key role. */
188
+ export const createBackupBucket: API.OperationMethod<
189
+ CreateBackupBucketRequest,
190
+ CreateBackupBucketResponse,
191
+ CreateBackupBucketError,
192
+ ClickHouseCloudOpContext
193
+ > = /*@__PURE__*/ API.make(() => ({
194
+ input: __S(2, __c0, 2) as any as S.Schema<CreateBackupBucketRequest>,
195
+ output: __S(12, __c1, 4) as any as S.Schema<CreateBackupBucketResponse>,
196
+ errors: [],
197
+ serviceErrors: ClickHouseCloudServiceErrors,
198
+ protocol: ClickHouseCloudProtocol,
199
+ retry: Retry.Retry,
200
+ telemetry: TELEMETRY,
201
+ span: "CreateBackupBucket",
202
+ }));
203
+
204
+ export type DeleteBackupBucketError = ClickHouseCloudOpError;
205
+ /** Delete service backup bucket **This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. <br /><br /> Delete service backup bucket. Requires ADMIN auth key role. */
206
+ export const deleteBackupBucket: API.OperationMethod<
207
+ DeleteBackupBucketRequest,
208
+ DeleteBackupBucketResponse,
209
+ DeleteBackupBucketError,
210
+ ClickHouseCloudOpContext
211
+ > = /*@__PURE__*/ API.make(() => ({
212
+ input: __S(24, __c3, 0) as any as S.Schema<DeleteBackupBucketRequest>,
213
+ output: __S(25, __c3, 1) as any as S.Schema<DeleteBackupBucketResponse>,
214
+ errors: [],
215
+ serviceErrors: ClickHouseCloudServiceErrors,
216
+ protocol: ClickHouseCloudProtocol,
217
+ retry: Retry.Retry,
218
+ telemetry: TELEMETRY,
219
+ span: "DeleteBackupBucket",
220
+ }));
221
+
222
+ export type GetBackupBucketError = ClickHouseCloudOpError;
223
+ /** Get service backup bucket **This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns the service backup bucket. */
224
+ export const getBackupBucket: API.OperationMethod<
225
+ GetBackupBucketRequest,
226
+ GetBackupBucketResponse,
227
+ GetBackupBucketError,
228
+ ClickHouseCloudOpContext
229
+ > = /*@__PURE__*/ API.make(() => ({
230
+ input: __S(32, __c4, 0) as any as S.Schema<GetBackupBucketRequest>,
231
+ output: __S(12, __c1, 4) as any as S.Schema<GetBackupBucketResponse>,
232
+ errors: [],
233
+ serviceErrors: ClickHouseCloudServiceErrors,
234
+ protocol: ClickHouseCloudProtocol,
235
+ retry: Retry.Retry,
236
+ telemetry: TELEMETRY,
237
+ span: "GetBackupBucket",
238
+ }));
239
+
240
+ export type UpdateBackupBucketError = ClickHouseCloudOpError;
241
+ /** Update service backup bucket **This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. <br /><br /> Update service backup bucket. Requires ADMIN auth key role. The secrets of the specified bucket provider are always required */
242
+ export const updateBackupBucket: API.OperationMethod<
243
+ UpdateBackupBucketRequest,
244
+ UpdateBackupBucketResponse,
245
+ UpdateBackupBucketError,
246
+ ClickHouseCloudOpContext
247
+ > = /*@__PURE__*/ API.make(() => ({
248
+ input: __S(42, __c5, 2) as any as S.Schema<UpdateBackupBucketRequest>,
249
+ output: __S(12, __c1, 4) as any as S.Schema<UpdateBackupBucketResponse>,
250
+ errors: [],
251
+ serviceErrors: ClickHouseCloudServiceErrors,
252
+ protocol: ClickHouseCloudProtocol,
253
+ retry: Retry.Retry,
254
+ telemetry: TELEMETRY,
255
+ span: "UpdateBackupBucket",
256
+ }));
257
+
258
+ // Schema builders: each runs one schema initializer, on that schema's first use.
259
+ function __c0(j: number): any {
260
+ switch (j) {
261
+ case 0:
262
+ return S.suspend(() =>
263
+ S.Struct({
264
+ bucketProvider: S.optional(S.String),
265
+ bucketPath: S.optional(S.String),
266
+ iamRoleArn: S.optional(S.String),
267
+ iamRoleSessionName: S.optional(S.String),
268
+ iamRoleExternalId: S.optional(S.String),
269
+ }),
270
+ ).annotate({ identifier: "AwsBackupBucketPostRequestV1" });
271
+ case 1:
272
+ return S.Union([__S(0, __c0, 0), __S(16, __c2, 0), __S(17, __c2, 1)]);
273
+ case 2:
274
+ return S.suspend(() =>
275
+ S.Struct({
276
+ organizationId: S.String.pipe(T.Label()),
277
+ serviceId: S.String.pipe(T.Label()),
278
+ body: S.optional(__S(1, __c0, 1).pipe(T.HttpBody())),
279
+ }).pipe(
280
+ T.Http({
281
+ method: "POST",
282
+ uri: "/v1/organizations/{organizationId}/services/{serviceId}/backupBucket",
283
+ code: 200,
284
+ }),
285
+ ),
286
+ ).annotate({ identifier: "CreateBackupBucketRequest" });
287
+ }
288
+ }
289
+ function __c1(j: number): any {
290
+ switch (j) {
291
+ case 0:
292
+ return S.suspend(() =>
293
+ S.Struct({
294
+ id: S.optional(S.String),
295
+ bucketProvider: S.optional(S.String),
296
+ bucketPath: S.optional(S.String),
297
+ iamRoleArn: S.optional(S.String),
298
+ iamRoleSessionName: S.optional(S.String),
299
+ iamRoleExternalId: S.optional(S.String),
300
+ }),
301
+ ).annotate({ identifier: "AwsBackupBucket" });
302
+ case 1:
303
+ return S.suspend(() =>
304
+ S.Struct({
305
+ id: S.optional(S.String),
306
+ bucketProvider: S.optional(S.String),
307
+ bucketPath: S.optional(S.String),
308
+ accessKeyId: S.optional(S.String),
309
+ }),
310
+ ).annotate({ identifier: "GcpBackupBucket" });
311
+ case 2:
312
+ return S.suspend(() =>
313
+ S.Struct({
314
+ id: S.optional(S.String),
315
+ bucketProvider: S.optional(S.String),
316
+ containerName: S.optional(S.String),
317
+ }),
318
+ ).annotate({ identifier: "AzureBackupBucket" });
319
+ case 3:
320
+ return S.Union([__S(8, __c1, 0), __S(9, __c1, 1), __S(10, __c1, 2)]);
321
+ case 4:
322
+ return S.suspend(() => __S(11, __c1, 3).pipe(T.RawResponseRoot())).annotate({
323
+ identifier: "CreateBackupBucketResponse",
324
+ });
325
+ }
326
+ }
327
+ function __c2(j: number): any {
328
+ switch (j) {
329
+ case 0:
330
+ return S.suspend(() =>
331
+ S.Struct({
332
+ bucketProvider: S.optional(S.String),
333
+ bucketPath: S.optional(S.String),
334
+ accessKeyId: S.optional(S.String),
335
+ secretAccessKey: S.optional(S.String.pipe(T.SensitiveValue({}))),
336
+ }),
337
+ ).annotate({ identifier: "GcpBackupBucketPostRequestV1" });
338
+ case 1:
339
+ return S.suspend(() =>
340
+ S.Struct({
341
+ bucketProvider: S.optional(S.String),
342
+ containerName: S.optional(S.String),
343
+ connectionString: S.optional(S.String.pipe(T.SensitiveValue({}))),
344
+ }),
345
+ ).annotate({ identifier: "AzureBackupBucketPostRequestV1" });
346
+ }
347
+ }
348
+ function __c3(j: number): any {
349
+ switch (j) {
350
+ case 0:
351
+ return S.suspend(() =>
352
+ S.Struct({
353
+ organizationId: S.String.pipe(T.Label()),
354
+ serviceId: S.String.pipe(T.Label()),
355
+ }).pipe(
356
+ T.Http({
357
+ method: "DELETE",
358
+ uri: "/v1/organizations/{organizationId}/services/{serviceId}/backupBucket",
359
+ code: 200,
360
+ }),
361
+ ),
362
+ ).annotate({ identifier: "DeleteBackupBucketRequest" });
363
+ case 1:
364
+ return S.suspend(() =>
365
+ S.Struct({
366
+ status: S.optional(S.Number),
367
+ requestId: S.optional(S.String),
368
+ }),
369
+ ).annotate({ identifier: "DeleteBackupBucketResponse" });
370
+ }
371
+ }
372
+ function __c4(j: number): any {
373
+ switch (j) {
374
+ case 0:
375
+ return S.suspend(() =>
376
+ S.Struct({
377
+ organizationId: S.String.pipe(T.Label()),
378
+ serviceId: S.String.pipe(T.Label()),
379
+ }).pipe(
380
+ T.Http({
381
+ method: "GET",
382
+ uri: "/v1/organizations/{organizationId}/services/{serviceId}/backupBucket",
383
+ code: 200,
384
+ }),
385
+ ),
386
+ ).annotate({ identifier: "GetBackupBucketRequest" });
387
+ }
388
+ }
389
+ function __c5(j: number): any {
390
+ switch (j) {
391
+ case 0:
392
+ return S.suspend(() =>
393
+ S.Struct({
394
+ bucketProvider: S.optional(S.String),
395
+ bucketPath: S.optional(S.String),
396
+ iamRoleArn: S.optional(S.String),
397
+ iamRoleSessionName: S.optional(S.NullOr(S.String)),
398
+ iamRoleExternalId: S.optional(S.NullOr(S.String)),
399
+ }),
400
+ ).annotate({ identifier: "AwsBackupBucketPatchRequestV1" });
401
+ case 1:
402
+ return S.Union([__S(40, __c5, 0), __S(16, __c2, 0), __S(17, __c2, 1)]);
403
+ case 2:
404
+ return S.suspend(() =>
405
+ S.Struct({
406
+ organizationId: S.String.pipe(T.Label()),
407
+ serviceId: S.String.pipe(T.Label()),
408
+ body: S.optional(__S(41, __c5, 1).pipe(T.HttpBody())),
409
+ }).pipe(
410
+ T.Http({
411
+ method: "PATCH",
412
+ uri: "/v1/organizations/{organizationId}/services/{serviceId}/backupBucket",
413
+ code: 200,
414
+ }),
415
+ ),
416
+ ).annotate({ identifier: "UpdateBackupBucketRequest" });
417
+ }
418
+ }
419
+ // Schema table: entry i is schema j of builder f, made on first reach.
420
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
421
+ return (__s[i] ??= __L.at(f, j));
422
+ }
@@ -0,0 +1,232 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-clickhouse-cloud/specs/openapi.json). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import { ClickHouseCloudServiceErrors } from "../errors.ts";
6
+ import {
7
+ ClickHouseCloudProtocol,
8
+ type ClickHouseCloudOpError,
9
+ type ClickHouseCloudOpContext,
10
+ } from "../protocol.ts";
11
+ import * as Retry from "../retry.ts";
12
+ import * as T from "../traits.ts";
13
+ // Schema table, filled on first reach (see __S at the end).
14
+ const __s: any[] = [];
15
+
16
+ export type { ClickHouseCloudOpError, ClickHouseCloudOpContext };
17
+
18
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
19
+ const TELEMETRY = {
20
+ system: "clickhouse-cloud-api",
21
+ responseHeaders: [
22
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
23
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
24
+ ],
25
+ prefix: "ClickhouseCloud",
26
+ service: "Billing",
27
+ labels: "clickhouse_cloud",
28
+ propagate: "w3c",
29
+ } as const;
30
+
31
+ export interface GetCreditBalancesRequest {
32
+ /** ID of the requested organization. */
33
+ organizationId: string;
34
+ }
35
+ /** Type of the balance. */
36
+ export type CreditBalanceType = "prepaid" | "trial";
37
+ export interface CreditBalance {
38
+ /** Unique ID of the balance. */
39
+ id?: string | undefined;
40
+ /** Type of the balance. */
41
+ type?: CreditBalanceType | undefined;
42
+ /** Remaining credits available on this balance, in ClickHouse Credits (CHCs). */
43
+ remainingCredits?: number | undefined;
44
+ /** Total credits granted on this balance, in ClickHouse Credits (CHCs). */
45
+ totalAmount?: number | undefined;
46
+ /** Credits spent from this balance, in ClickHouse Credits (CHCs). */
47
+ amountSpent?: number | undefined;
48
+ /** Date the balance became active. ISO-8601, based on the UTC timezone. */
49
+ startDate?: string | undefined;
50
+ /** Date the balance expires. ISO-8601, based on the UTC timezone. */
51
+ expirationDate?: string | undefined;
52
+ }
53
+ /** List of active balances for the organization. Empty when the organization has none. */
54
+ export type CreditBalancesBalancesList = Array<CreditBalance>;
55
+ export interface CreditBalances {
56
+ /** Total remaining credits across all active balances, in ClickHouse Credits (CHCs). */
57
+ totalRemainingCredits?: number | undefined;
58
+ /** List of active balances for the organization. Empty when the organization has none. */
59
+ balances?: CreditBalancesBalancesList | undefined;
60
+ }
61
+ export interface GetInferenceUsageCostRequest {
62
+ /** ID of the requested organization. */
63
+ organizationId: string;
64
+ /** Start date for the report, e.g. 2024-12-19. */
65
+ from_date: string;
66
+ /** End date (inclusive) for the report, e.g. 2024-12-20. This date cannot be more than 30 days after from_date (for a maximum queried period of 31 days). */
67
+ to_date: string;
68
+ }
69
+ export interface InferenceUsageCostMetric {
70
+ /** Name of the metric: `input`, `output`, `cache_read`, `cache_write_5m`, `cache_write_30m` or `cache_write_1h`. New values can appear. */
71
+ metric?: string | undefined;
72
+ /** Number of tokens used, in millions. For example, 1.5 means 1,500,000 tokens. */
73
+ tokensMillions?: number | undefined;
74
+ /** Average price per million tokens in ClickHouse Credits (CHCs): `totalCHC` divided by `tokensMillions`. It is an average because one model can have more than one price. Zero when no tokens were used. */
75
+ pricePerMillionTokensCHC?: number | undefined;
76
+ /** Cost of the tokens used in ClickHouse Credits (CHCs). */
77
+ totalCHC?: number | undefined;
78
+ }
79
+ /** Usage and cost for each metric that has usage. The costs add up to `totalCHC`. */
80
+ export type InferenceUsageCostRecordMetricsList = Array<InferenceUsageCostMetric>;
81
+ export interface InferenceUsageCostRecord {
82
+ /** Date of the usage. ISO-8601 date, based on the UTC timezone. */
83
+ date?: string | undefined;
84
+ /** Provider of the model. */
85
+ provider?: string | undefined;
86
+ /** ID of the model. This is the raw model ID; `modelName` has the display name. */
87
+ model?: string | undefined;
88
+ /** Display name of the model, as the usage page and the usage statement CSV show it. */
89
+ modelName?: string | undefined;
90
+ /** Usage and cost for each metric that has usage. The costs add up to `totalCHC`. */
91
+ metrics?: InferenceUsageCostRecordMetricsList | undefined;
92
+ /** Total cost of usage in ClickHouse Credits (CHCs) for this model on this date. */
93
+ totalCHC?: number | undefined;
94
+ /** When true, the record is immutable. Unlocked records are subject to change until locked. */
95
+ locked?: boolean | undefined;
96
+ }
97
+ /** List of AI inference usage cost records, one per day, provider and model. Empty when the organization has no usage. */
98
+ export type InferenceUsageCostCostsList = Array<InferenceUsageCostRecord>;
99
+ export interface InferenceUsageCost {
100
+ /** Grand total cost of AI inference usage in ClickHouse Credits (CHCs). */
101
+ grandTotalCHC?: number | undefined;
102
+ /** List of AI inference usage cost records, one per day, provider and model. Empty when the organization has no usage. */
103
+ costs?: InferenceUsageCostCostsList | undefined;
104
+ }
105
+ export type GetCreditBalancesError = ClickHouseCloudOpError;
106
+ /** Get organization active credit balances **Disclaimer:** This beta endpoint is evolving; the API contract may change. <br /><br /> Returns the active credit balances for the organization, each with its own balance ID, type and remaining credits, along with the total remaining credits across all of them. A balance is active when it has started, has not expired, and has credits remaining. Balances are ordered by expiration date, soonest first. The list is always present and is empty when the organization has no active balances. */
107
+ export const getCreditBalances: API.OperationMethod<
108
+ GetCreditBalancesRequest,
109
+ CreditBalances,
110
+ GetCreditBalancesError,
111
+ ClickHouseCloudOpContext
112
+ > = /*@__PURE__*/ API.make(() => ({
113
+ input: __S(0, __c0, 0) as any as S.Schema<GetCreditBalancesRequest>,
114
+ output: __S(3, __c0, 3) as any as S.Schema<CreditBalances>,
115
+ errors: [],
116
+ serviceErrors: ClickHouseCloudServiceErrors,
117
+ protocol: ClickHouseCloudProtocol,
118
+ retry: Retry.Retry,
119
+ telemetry: TELEMETRY,
120
+ span: "GetCreditBalances",
121
+ }));
122
+
123
+ export type GetInferenceUsageCostError = ClickHouseCloudOpError;
124
+ /** Get organization AI inference usage costs **Disclaimer:** This beta endpoint is evolving; the API contract may change. <br /><br /> Returns a grand total and a list of daily AI inference usage cost records for the organization in the queried time period (maximum 31 days). There is one record per day, provider and model. Each record lists the tokens used, the average price and the cost for each metric, such as input, output, cache read and each cache write duration. All costs are at list price. All days in both the request and the response are evaluated based on the UTC timezone. */
125
+ export const getInferenceUsageCost: API.OperationMethod<
126
+ GetInferenceUsageCostRequest,
127
+ InferenceUsageCost,
128
+ GetInferenceUsageCostError,
129
+ ClickHouseCloudOpContext
130
+ > = /*@__PURE__*/ API.make(() => ({
131
+ input: __S(8, __c1, 0) as any as S.Schema<GetInferenceUsageCostRequest>,
132
+ output: __S(13, __c1, 5) as any as S.Schema<InferenceUsageCost>,
133
+ errors: [],
134
+ serviceErrors: ClickHouseCloudServiceErrors,
135
+ protocol: ClickHouseCloudProtocol,
136
+ retry: Retry.Retry,
137
+ telemetry: TELEMETRY,
138
+ span: "GetInferenceUsageCost",
139
+ }));
140
+
141
+ // Schema builders: each runs one schema initializer, on that schema's first use.
142
+ function __c0(j: number): any {
143
+ switch (j) {
144
+ case 0:
145
+ return S.suspend(() =>
146
+ S.Struct({
147
+ organizationId: S.String.pipe(T.Label()),
148
+ }).pipe(
149
+ T.Http({
150
+ method: "GET",
151
+ uri: "/v1/organizations/{organizationId}/creditBalances",
152
+ code: 200,
153
+ }),
154
+ ),
155
+ ).annotate({ identifier: "GetCreditBalancesRequest" });
156
+ case 1:
157
+ return S.suspend(() =>
158
+ S.Struct({
159
+ id: S.optional(S.String),
160
+ type: S.optional(S.String),
161
+ remainingCredits: S.optional(S.Number),
162
+ totalAmount: S.optional(S.Number),
163
+ amountSpent: S.optional(S.Number),
164
+ startDate: S.optional(S.String),
165
+ expirationDate: S.optional(S.String),
166
+ }),
167
+ ).annotate({ identifier: "CreditBalance" });
168
+ case 2:
169
+ return S.Array(__S(1, __c0, 1));
170
+ case 3:
171
+ return S.suspend(() =>
172
+ S.Struct({
173
+ totalRemainingCredits: S.optional(S.Number),
174
+ balances: S.optional(__S(2, __c0, 2)),
175
+ }),
176
+ ).annotate({ identifier: "CreditBalances" });
177
+ }
178
+ }
179
+ function __c1(j: number): any {
180
+ switch (j) {
181
+ case 0:
182
+ return S.suspend(() =>
183
+ S.Struct({
184
+ organizationId: S.String.pipe(T.Label()),
185
+ from_date: S.String.pipe(T.Query()),
186
+ to_date: S.String.pipe(T.Query()),
187
+ }).pipe(
188
+ T.Http({
189
+ method: "GET",
190
+ uri: "/v1/organizations/{organizationId}/inferenceUsageCost",
191
+ code: 200,
192
+ }),
193
+ ),
194
+ ).annotate({ identifier: "GetInferenceUsageCostRequest" });
195
+ case 1:
196
+ return S.suspend(() =>
197
+ S.Struct({
198
+ metric: S.optional(S.String),
199
+ tokensMillions: S.optional(S.Number),
200
+ pricePerMillionTokensCHC: S.optional(S.Number),
201
+ totalCHC: S.optional(S.Number),
202
+ }),
203
+ ).annotate({ identifier: "InferenceUsageCostMetric" });
204
+ case 2:
205
+ return S.Array(__S(9, __c1, 1));
206
+ case 3:
207
+ return S.suspend(() =>
208
+ S.Struct({
209
+ date: S.optional(S.String),
210
+ provider: S.optional(S.String),
211
+ model: S.optional(S.String),
212
+ modelName: S.optional(S.String),
213
+ metrics: S.optional(__S(10, __c1, 2)),
214
+ totalCHC: S.optional(S.Number),
215
+ locked: S.optional(S.Boolean),
216
+ }),
217
+ ).annotate({ identifier: "InferenceUsageCostRecord" });
218
+ case 4:
219
+ return S.Array(__S(11, __c1, 3));
220
+ case 5:
221
+ return S.suspend(() =>
222
+ S.Struct({
223
+ grandTotalCHC: S.optional(S.Number),
224
+ costs: S.optional(__S(12, __c1, 4)),
225
+ }),
226
+ ).annotate({ identifier: "InferenceUsageCost" });
227
+ }
228
+ }
229
+ // Schema table: entry i is schema j of builder f, made on first reach.
230
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
231
+ return (__s[i] ??= __L.at(f, j));
232
+ }