@metronome/sdk 0.1.0-alpha.0

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 (284) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +201 -0
  3. package/README.md +313 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +90 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +237 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +868 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +837 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +53 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +143 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +127 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +210 -0
  87. package/index.d.ts +210 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +133 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +105 -0
  92. package/index.mjs.map +1 -0
  93. package/package.json +106 -0
  94. package/resource.d.ts +6 -0
  95. package/resource.d.ts.map +1 -0
  96. package/resource.js +11 -0
  97. package/resource.js.map +1 -0
  98. package/resource.mjs +7 -0
  99. package/resource.mjs.map +1 -0
  100. package/resources/alerts.d.ts +103 -0
  101. package/resources/alerts.d.ts.map +1 -0
  102. package/resources/alerts.js +23 -0
  103. package/resources/alerts.js.map +1 -0
  104. package/resources/alerts.mjs +19 -0
  105. package/resources/alerts.mjs.map +1 -0
  106. package/resources/audit-logs.d.ts +83 -0
  107. package/resources/audit-logs.d.ts.map +1 -0
  108. package/resources/audit-logs.js +18 -0
  109. package/resources/audit-logs.js.map +1 -0
  110. package/resources/audit-logs.mjs +14 -0
  111. package/resources/audit-logs.mjs.map +1 -0
  112. package/resources/billable-metrics.d.ts +236 -0
  113. package/resources/billable-metrics.d.ts.map +1 -0
  114. package/resources/billable-metrics.js +36 -0
  115. package/resources/billable-metrics.js.map +1 -0
  116. package/resources/billable-metrics.mjs +32 -0
  117. package/resources/billable-metrics.mjs.map +1 -0
  118. package/resources/credit-grants.d.ts +469 -0
  119. package/resources/credit-grants.d.ts.map +1 -0
  120. package/resources/credit-grants.js +50 -0
  121. package/resources/credit-grants.js.map +1 -0
  122. package/resources/credit-grants.mjs +46 -0
  123. package/resources/credit-grants.mjs.map +1 -0
  124. package/resources/custom-fields.d.ts +82 -0
  125. package/resources/custom-fields.d.ts.map +1 -0
  126. package/resources/custom-fields.js +66 -0
  127. package/resources/custom-fields.js.map +1 -0
  128. package/resources/custom-fields.mjs +62 -0
  129. package/resources/custom-fields.mjs.map +1 -0
  130. package/resources/customers/alerts.d.ts +146 -0
  131. package/resources/customers/alerts.d.ts.map +1 -0
  132. package/resources/customers/alerts.js +35 -0
  133. package/resources/customers/alerts.js.map +1 -0
  134. package/resources/customers/alerts.mjs +31 -0
  135. package/resources/customers/alerts.mjs.map +1 -0
  136. package/resources/customers/billing-config.d.ts +64 -0
  137. package/resources/customers/billing-config.d.ts.map +1 -0
  138. package/resources/customers/billing-config.js +37 -0
  139. package/resources/customers/billing-config.js.map +1 -0
  140. package/resources/customers/billing-config.mjs +33 -0
  141. package/resources/customers/billing-config.mjs.map +1 -0
  142. package/resources/customers/customers.d.ts +313 -0
  143. package/resources/customers/customers.d.ts.map +1 -0
  144. package/resources/customers/customers.js +116 -0
  145. package/resources/customers/customers.js.map +1 -0
  146. package/resources/customers/customers.mjs +89 -0
  147. package/resources/customers/customers.mjs.map +1 -0
  148. package/resources/customers/index.d.ts +6 -0
  149. package/resources/customers/index.d.ts.map +1 -0
  150. package/resources/customers/index.js +15 -0
  151. package/resources/customers/index.js.map +1 -0
  152. package/resources/customers/index.mjs +7 -0
  153. package/resources/customers/index.mjs.map +1 -0
  154. package/resources/customers/invoices.d.ts +331 -0
  155. package/resources/customers/invoices.d.ts.map +1 -0
  156. package/resources/customers/invoices.js +30 -0
  157. package/resources/customers/invoices.js.map +1 -0
  158. package/resources/customers/invoices.mjs +26 -0
  159. package/resources/customers/invoices.mjs.map +1 -0
  160. package/resources/customers/plans.d.ts +239 -0
  161. package/resources/customers/plans.d.ts.map +1 -0
  162. package/resources/customers/plans.js +41 -0
  163. package/resources/customers/plans.js.map +1 -0
  164. package/resources/customers/plans.mjs +37 -0
  165. package/resources/customers/plans.mjs.map +1 -0
  166. package/resources/dashboards.d.ts +61 -0
  167. package/resources/dashboards.d.ts.map +1 -0
  168. package/resources/dashboards.js +19 -0
  169. package/resources/dashboards.js.map +1 -0
  170. package/resources/dashboards.mjs +15 -0
  171. package/resources/dashboards.mjs.map +1 -0
  172. package/resources/index.d.ts +13 -0
  173. package/resources/index.d.ts.map +1 -0
  174. package/resources/index.js +42 -0
  175. package/resources/index.js.map +1 -0
  176. package/resources/index.mjs +14 -0
  177. package/resources/index.mjs.map +1 -0
  178. package/resources/plans.d.ts +217 -0
  179. package/resources/plans.d.ts.map +1 -0
  180. package/resources/plans.js +36 -0
  181. package/resources/plans.js.map +1 -0
  182. package/resources/plans.mjs +32 -0
  183. package/resources/plans.mjs.map +1 -0
  184. package/resources/services.d.ts +26 -0
  185. package/resources/services.d.ts.map +1 -0
  186. package/resources/services.js +20 -0
  187. package/resources/services.js.map +1 -0
  188. package/resources/services.mjs +16 -0
  189. package/resources/services.mjs.map +1 -0
  190. package/resources/shared.d.ts +540 -0
  191. package/resources/shared.d.ts.map +1 -0
  192. package/resources/shared.js +4 -0
  193. package/resources/shared.js.map +1 -0
  194. package/resources/shared.mjs +3 -0
  195. package/resources/shared.mjs.map +1 -0
  196. package/resources/usage.d.ts +182 -0
  197. package/resources/usage.d.ts.map +1 -0
  198. package/resources/usage.js +41 -0
  199. package/resources/usage.js.map +1 -0
  200. package/resources/usage.mjs +37 -0
  201. package/resources/usage.mjs.map +1 -0
  202. package/resources/webhooks.d.ts +22 -0
  203. package/resources/webhooks.d.ts.map +1 -0
  204. package/resources/webhooks.js +91 -0
  205. package/resources/webhooks.js.map +1 -0
  206. package/resources/webhooks.mjs +87 -0
  207. package/resources/webhooks.mjs.map +1 -0
  208. package/shims/node.d.ts +29 -0
  209. package/shims/node.d.ts.map +1 -0
  210. package/shims/node.js +31 -0
  211. package/shims/node.js.map +1 -0
  212. package/shims/node.mjs +5 -0
  213. package/shims/node.mjs.map +1 -0
  214. package/shims/web.d.ts +26 -0
  215. package/shims/web.d.ts.map +1 -0
  216. package/shims/web.js +31 -0
  217. package/shims/web.js.map +1 -0
  218. package/shims/web.mjs +5 -0
  219. package/shims/web.mjs.map +1 -0
  220. package/src/_shims/MultipartBody.ts +9 -0
  221. package/src/_shims/README.md +46 -0
  222. package/src/_shims/auto/runtime-bun.ts +4 -0
  223. package/src/_shims/auto/runtime-node.ts +4 -0
  224. package/src/_shims/auto/runtime.ts +4 -0
  225. package/src/_shims/auto/types-node.ts +4 -0
  226. package/src/_shims/auto/types.d.ts +101 -0
  227. package/src/_shims/auto/types.js +3 -0
  228. package/src/_shims/auto/types.mjs +3 -0
  229. package/src/_shims/bun-runtime.ts +14 -0
  230. package/src/_shims/index.d.ts +81 -0
  231. package/src/_shims/index.js +13 -0
  232. package/src/_shims/index.mjs +7 -0
  233. package/src/_shims/manual-types.d.ts +12 -0
  234. package/src/_shims/manual-types.js +3 -0
  235. package/src/_shims/manual-types.mjs +3 -0
  236. package/src/_shims/node-runtime.ts +83 -0
  237. package/src/_shims/node-types.d.ts +42 -0
  238. package/src/_shims/node-types.js +3 -0
  239. package/src/_shims/node-types.mjs +3 -0
  240. package/src/_shims/registry.ts +67 -0
  241. package/src/_shims/web-runtime.ts +103 -0
  242. package/src/_shims/web-types.d.ts +83 -0
  243. package/src/_shims/web-types.js +3 -0
  244. package/src/_shims/web-types.mjs +3 -0
  245. package/src/core.ts +1146 -0
  246. package/src/error.ts +146 -0
  247. package/src/index.ts +303 -0
  248. package/src/lib/.keep +4 -0
  249. package/src/resource.ts +11 -0
  250. package/src/resources/alerts.ts +144 -0
  251. package/src/resources/audit-logs.ts +116 -0
  252. package/src/resources/billable-metrics.ts +341 -0
  253. package/src/resources/credit-grants.ts +627 -0
  254. package/src/resources/custom-fields.ts +242 -0
  255. package/src/resources/customers/alerts.ts +214 -0
  256. package/src/resources/customers/billing-config.ts +183 -0
  257. package/src/resources/customers/customers.ts +500 -0
  258. package/src/resources/customers/index.ts +53 -0
  259. package/src/resources/customers/invoices.ts +533 -0
  260. package/src/resources/customers/plans.ts +363 -0
  261. package/src/resources/dashboards.ts +98 -0
  262. package/src/resources/index.ts +90 -0
  263. package/src/resources/plans.ts +333 -0
  264. package/src/resources/services.ts +35 -0
  265. package/src/resources/shared.ts +849 -0
  266. package/src/resources/usage.ts +245 -0
  267. package/src/resources/webhooks.ts +120 -0
  268. package/src/shims/node.ts +50 -0
  269. package/src/shims/web.ts +50 -0
  270. package/src/tsconfig.json +11 -0
  271. package/src/uploads.ts +248 -0
  272. package/src/version.ts +1 -0
  273. package/uploads.d.ts +75 -0
  274. package/uploads.d.ts.map +1 -0
  275. package/uploads.js +165 -0
  276. package/uploads.js.map +1 -0
  277. package/uploads.mjs +152 -0
  278. package/uploads.mjs.map +1 -0
  279. package/version.d.ts +2 -0
  280. package/version.d.ts.map +1 -0
  281. package/version.js +5 -0
  282. package/version.js.map +1 -0
  283. package/version.mjs +2 -0
  284. package/version.mjs.map +1 -0
@@ -0,0 +1,242 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import { isRequestOptions } from "../core";
6
+ import * as CustomFieldsAPI from "./custom-fields";
7
+
8
+ export class CustomFields extends APIResource {
9
+ /**
10
+ * Add a key to the allow list for a given entity. There is a 100 character limit
11
+ * on custom field keys.
12
+ */
13
+ addKey(body: CustomFieldAddKeyParams, options?: Core.RequestOptions): Core.APIPromise<void> {
14
+ return this._client.post('/customFields/addKey', {
15
+ body,
16
+ ...options,
17
+ headers: { Accept: '*/*', ...options?.headers },
18
+ });
19
+ }
20
+
21
+ /**
22
+ * Deletes one or more custom fields on an instance of a Metronome entity.
23
+ */
24
+ deleteValues(body: CustomFieldDeleteValuesParams, options?: Core.RequestOptions): Core.APIPromise<void> {
25
+ return this._client.post('/customFields/deleteValues', {
26
+ body,
27
+ ...options,
28
+ headers: { Accept: '*/*', ...options?.headers },
29
+ });
30
+ }
31
+
32
+ /**
33
+ * List all active custom field keys, optionally filtered by entity type.
34
+ */
35
+ listKeys(
36
+ params?: CustomFieldListKeysParams,
37
+ options?: Core.RequestOptions,
38
+ ): Core.APIPromise<CustomFieldListKeysResponse>;
39
+ listKeys(options?: Core.RequestOptions): Core.APIPromise<CustomFieldListKeysResponse>;
40
+ listKeys(
41
+ params: CustomFieldListKeysParams | Core.RequestOptions = {},
42
+ options?: Core.RequestOptions,
43
+ ): Core.APIPromise<CustomFieldListKeysResponse> {
44
+ if (isRequestOptions(params)) {
45
+ return this.listKeys({}, params);
46
+ }
47
+ const { next_page, ...body } = params;
48
+ return this._client.post('/customFields/listKeys', { query: { next_page }, body, ...options });
49
+ }
50
+
51
+ /**
52
+ * Remove a key from the allow list for a given entity.
53
+ */
54
+ removeKey(body: CustomFieldRemoveKeyParams, options?: Core.RequestOptions): Core.APIPromise<void> {
55
+ return this._client.post('/customFields/removeKey', {
56
+ body,
57
+ ...options,
58
+ headers: { Accept: '*/*', ...options?.headers },
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Sets one or more custom fields on an instance of a Metronome entity. If a
64
+ * key/value pair passed in this request matches one already set on the entity, its
65
+ * value will be overwritten. Any key/value pairs that exist on the entity that do
66
+ * not match those passed in this request will remain untouched. This endpoint is
67
+ * transactional and will update all key/value pairs or no key/value pairs. Partial
68
+ * updates are not supported. There is a 200 character limit on custom field
69
+ * values.
70
+ */
71
+ setValues(body: CustomFieldSetValuesParams, options?: Core.RequestOptions): Core.APIPromise<void> {
72
+ return this._client.post('/customFields/setValues', {
73
+ body,
74
+ ...options,
75
+ headers: { Accept: '*/*', ...options?.headers },
76
+ });
77
+ }
78
+ }
79
+
80
+ export interface CustomFieldListKeysResponse {
81
+ data: Array<CustomFieldListKeysResponse.Data>;
82
+
83
+ next_page: string | null;
84
+ }
85
+
86
+ export namespace CustomFieldListKeysResponse {
87
+ export interface Data {
88
+ enforce_uniqueness: boolean;
89
+
90
+ entity:
91
+ | 'alert'
92
+ | 'billable_metric'
93
+ | 'charge'
94
+ | 'commit'
95
+ | 'contract_credit'
96
+ | 'contract_product'
97
+ | 'contract'
98
+ | 'credit_grant'
99
+ | 'customer_plan'
100
+ | 'customer'
101
+ | 'invoice'
102
+ | 'plan'
103
+ | 'professional_service'
104
+ | 'product'
105
+ | 'rate_card'
106
+ | 'scheduled_charge';
107
+
108
+ key: string;
109
+ }
110
+ }
111
+
112
+ export interface CustomFieldAddKeyParams {
113
+ enforce_uniqueness: boolean;
114
+
115
+ entity:
116
+ | 'alert'
117
+ | 'billable_metric'
118
+ | 'charge'
119
+ | 'commit'
120
+ | 'contract_credit'
121
+ | 'contract_product'
122
+ | 'contract'
123
+ | 'credit_grant'
124
+ | 'customer_plan'
125
+ | 'customer'
126
+ | 'invoice'
127
+ | 'plan'
128
+ | 'professional_service'
129
+ | 'product'
130
+ | 'rate_card'
131
+ | 'scheduled_charge';
132
+
133
+ key: string;
134
+ }
135
+
136
+ export interface CustomFieldDeleteValuesParams {
137
+ entity:
138
+ | 'alert'
139
+ | 'billable_metric'
140
+ | 'charge'
141
+ | 'commit'
142
+ | 'contract_credit'
143
+ | 'contract_product'
144
+ | 'contract'
145
+ | 'credit_grant'
146
+ | 'customer_plan'
147
+ | 'customer'
148
+ | 'invoice'
149
+ | 'plan'
150
+ | 'professional_service'
151
+ | 'product'
152
+ | 'rate_card'
153
+ | 'scheduled_charge';
154
+
155
+ entity_id: string;
156
+
157
+ keys: Array<string>;
158
+ }
159
+
160
+ export interface CustomFieldListKeysParams {
161
+ /**
162
+ * Query param: Cursor that indicates where the next page of results should start.
163
+ */
164
+ next_page?: string;
165
+
166
+ /**
167
+ * Body param: Optional list of entity types to return keys for
168
+ */
169
+ entities?: Array<
170
+ | 'alert'
171
+ | 'billable_metric'
172
+ | 'charge'
173
+ | 'commit'
174
+ | 'contract_credit'
175
+ | 'contract_product'
176
+ | 'contract'
177
+ | 'credit_grant'
178
+ | 'customer_plan'
179
+ | 'customer'
180
+ | 'invoice'
181
+ | 'plan'
182
+ | 'professional_service'
183
+ | 'product'
184
+ | 'rate_card'
185
+ | 'scheduled_charge'
186
+ >;
187
+ }
188
+
189
+ export interface CustomFieldRemoveKeyParams {
190
+ entity:
191
+ | 'alert'
192
+ | 'billable_metric'
193
+ | 'charge'
194
+ | 'commit'
195
+ | 'contract_credit'
196
+ | 'contract_product'
197
+ | 'contract'
198
+ | 'credit_grant'
199
+ | 'customer_plan'
200
+ | 'customer'
201
+ | 'invoice'
202
+ | 'plan'
203
+ | 'professional_service'
204
+ | 'product'
205
+ | 'rate_card'
206
+ | 'scheduled_charge';
207
+
208
+ key: string;
209
+ }
210
+
211
+ export interface CustomFieldSetValuesParams {
212
+ custom_fields: Record<string, string>;
213
+
214
+ entity:
215
+ | 'alert'
216
+ | 'billable_metric'
217
+ | 'charge'
218
+ | 'commit'
219
+ | 'contract_credit'
220
+ | 'contract_product'
221
+ | 'contract'
222
+ | 'credit_grant'
223
+ | 'customer_plan'
224
+ | 'customer'
225
+ | 'invoice'
226
+ | 'plan'
227
+ | 'professional_service'
228
+ | 'product'
229
+ | 'rate_card'
230
+ | 'scheduled_charge';
231
+
232
+ entity_id: string;
233
+ }
234
+
235
+ export namespace CustomFields {
236
+ export import CustomFieldListKeysResponse = CustomFieldsAPI.CustomFieldListKeysResponse;
237
+ export import CustomFieldAddKeyParams = CustomFieldsAPI.CustomFieldAddKeyParams;
238
+ export import CustomFieldDeleteValuesParams = CustomFieldsAPI.CustomFieldDeleteValuesParams;
239
+ export import CustomFieldListKeysParams = CustomFieldsAPI.CustomFieldListKeysParams;
240
+ export import CustomFieldRemoveKeyParams = CustomFieldsAPI.CustomFieldRemoveKeyParams;
241
+ export import CustomFieldSetValuesParams = CustomFieldsAPI.CustomFieldSetValuesParams;
242
+ }
@@ -0,0 +1,214 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import * as AlertsAPI from "./alerts";
6
+ import * as Shared from "../shared";
7
+
8
+ export class Alerts extends APIResource {
9
+ /**
10
+ * Get the customer alert status and alert information for the specified customer
11
+ * and alert
12
+ */
13
+ retrieve(body: AlertRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<AlertRetrieveResponse> {
14
+ return this._client.post('/customer-alerts/get', { body, ...options });
15
+ }
16
+
17
+ /**
18
+ * Fetch all customer alert statuses and alert information for a customer
19
+ */
20
+ list(params: AlertListParams, options?: Core.RequestOptions): Core.APIPromise<AlertListResponse> {
21
+ const { next_page, ...body } = params;
22
+ return this._client.post('/customer-alerts/list', { query: { next_page }, body, ...options });
23
+ }
24
+
25
+ /**
26
+ * Reset state for an alert by customer id and force re-evaluation
27
+ */
28
+ reset(body: AlertResetParams, options?: Core.RequestOptions): Core.APIPromise<void> {
29
+ return this._client.post('/customer-alerts/reset', {
30
+ body,
31
+ ...options,
32
+ headers: { Accept: '*/*', ...options?.headers },
33
+ });
34
+ }
35
+ }
36
+
37
+ export interface CustomerAlert {
38
+ alert: CustomerAlert.Alert;
39
+
40
+ /**
41
+ * The status of the customer alert. If the alert is archived, null will be
42
+ * returned.
43
+ */
44
+ customer_status: 'ok' | 'in_alarm' | 'evaluating' | null;
45
+
46
+ /**
47
+ * If present, indicates the reason the alert was triggered.
48
+ */
49
+ triggered_by?: string | null;
50
+ }
51
+
52
+ export namespace CustomerAlert {
53
+ export interface Alert {
54
+ /**
55
+ * the Metronome ID of the alert
56
+ */
57
+ id: string;
58
+
59
+ /**
60
+ * Name of the alert
61
+ */
62
+ name: string;
63
+
64
+ /**
65
+ * Status of the alert
66
+ */
67
+ status: 'enabled' | 'archived' | 'disabled';
68
+
69
+ /**
70
+ * Threshold value of the alert policy
71
+ */
72
+ threshold: number;
73
+
74
+ /**
75
+ * Type of the alert
76
+ */
77
+ type:
78
+ | 'low_credit_balance_reached'
79
+ | 'spend_threshold_reached'
80
+ | 'monthly_invoice_total_spend_threshold_reached'
81
+ | 'low_remaining_days_in_plan_reached'
82
+ | 'low_remaining_credit_percentage_reached'
83
+ | 'usage_threshold_reached'
84
+ | 'low_remaining_days_for_commit_segment_reached'
85
+ | 'low_remaining_commit_balance_reached'
86
+ | 'low_remaining_commit_percentage_reached'
87
+ | 'low_remaining_days_for_contract_credit_segment_reached'
88
+ | 'low_remaining_contract_credit_balance_reached'
89
+ | 'low_remaining_contract_credit_percentage_reached'
90
+ | 'invoice_total_reached';
91
+
92
+ /**
93
+ * Timestamp for when the alert was last updated
94
+ */
95
+ updated_at: string;
96
+
97
+ credit_type?: Shared.CreditType | null;
98
+
99
+ /**
100
+ * A list of custom field filters for alert types that support advanced filtering
101
+ */
102
+ custom_field_filters?: Array<Alert.CustomFieldFilter>;
103
+
104
+ /**
105
+ * Scopes alert evaluation to a specific presentation group key on individual line
106
+ * items. Only present for spend alerts.
107
+ */
108
+ group_key_filter?: Alert.GroupKeyFilter;
109
+
110
+ /**
111
+ * Only supported for invoice_total_reached alerts. A list of invoice types to
112
+ * evaluate.
113
+ */
114
+ invoice_types_filter?: Array<string>;
115
+
116
+ /**
117
+ * Prevents the creation of duplicates. If a request to create a record is made
118
+ * with a previously used uniqueness key, a new record will not be created and the
119
+ * request will fail with a 409 error.
120
+ */
121
+ uniqueness_key?: string;
122
+ }
123
+
124
+ export namespace Alert {
125
+ export interface CustomFieldFilter {
126
+ entity: 'Contract' | 'Commit' | 'ContractCredit';
127
+
128
+ key: string;
129
+
130
+ value: string;
131
+ }
132
+
133
+ /**
134
+ * Scopes alert evaluation to a specific presentation group key on individual line
135
+ * items. Only present for spend alerts.
136
+ */
137
+ export interface GroupKeyFilter {
138
+ key: string;
139
+
140
+ value: string;
141
+ }
142
+ }
143
+ }
144
+
145
+ export interface AlertRetrieveResponse {
146
+ data: CustomerAlert;
147
+ }
148
+
149
+ export interface AlertListResponse {
150
+ data: Array<CustomerAlert>;
151
+
152
+ next_page: string | null;
153
+ }
154
+
155
+ export interface AlertRetrieveParams {
156
+ /**
157
+ * The Metronome ID of the alert
158
+ */
159
+ alert_id: string;
160
+
161
+ /**
162
+ * The Metronome ID of the customer
163
+ */
164
+ customer_id: string;
165
+ }
166
+
167
+ export interface AlertListParams {
168
+ /**
169
+ * Body param: The Metronome ID of the customer
170
+ */
171
+ customer_id: string;
172
+
173
+ /**
174
+ * Query param: Cursor that indicates where the next page of results should start.
175
+ */
176
+ next_page?: string;
177
+
178
+ /**
179
+ * Body param: Optionally filter by alert status. If absent, only enabled alerts
180
+ * will be returned.
181
+ */
182
+ alert_statuses?: Array<
183
+ | 'enabled'
184
+ | 'disabled'
185
+ | 'archived'
186
+ | 'ENABLED'
187
+ | 'DISABLED'
188
+ | 'ARCHIVED'
189
+ | 'Enabled'
190
+ | 'Disabled'
191
+ | 'Archived'
192
+ >;
193
+ }
194
+
195
+ export interface AlertResetParams {
196
+ /**
197
+ * The Metronome ID of the alert
198
+ */
199
+ alert_id: string;
200
+
201
+ /**
202
+ * The Metronome ID of the customer
203
+ */
204
+ customer_id: string;
205
+ }
206
+
207
+ export namespace Alerts {
208
+ export import CustomerAlert = AlertsAPI.CustomerAlert;
209
+ export import AlertRetrieveResponse = AlertsAPI.AlertRetrieveResponse;
210
+ export import AlertListResponse = AlertsAPI.AlertListResponse;
211
+ export import AlertRetrieveParams = AlertsAPI.AlertRetrieveParams;
212
+ export import AlertListParams = AlertsAPI.AlertListParams;
213
+ export import AlertResetParams = AlertsAPI.AlertResetParams;
214
+ }
@@ -0,0 +1,183 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import * as BillingConfigAPI from "./billing-config";
6
+
7
+ export class BillingConfig extends APIResource {
8
+ /**
9
+ * Set the billing configuration for a given customer.
10
+ */
11
+ create(
12
+ customerId: string,
13
+ billingProviderType:
14
+ | 'aws_marketplace'
15
+ | 'stripe'
16
+ | 'netsuite'
17
+ | 'custom'
18
+ | 'azure_marketplace'
19
+ | 'quickbooks_online'
20
+ | 'workday'
21
+ | 'gcp_marketplace',
22
+ body: BillingConfigCreateParams,
23
+ options?: Core.RequestOptions,
24
+ ): Core.APIPromise<void> {
25
+ return this._client.post(`/customers/${customerId}/billing-config/${billingProviderType}`, {
26
+ body,
27
+ ...options,
28
+ headers: { Accept: '*/*', ...options?.headers },
29
+ });
30
+ }
31
+
32
+ /**
33
+ * Fetch the billing configuration for the given customer.
34
+ */
35
+ retrieve(
36
+ customerId: string,
37
+ billingProviderType:
38
+ | 'aws_marketplace'
39
+ | 'stripe'
40
+ | 'netsuite'
41
+ | 'custom'
42
+ | 'azure_marketplace'
43
+ | 'quickbooks_online'
44
+ | 'workday'
45
+ | 'gcp_marketplace',
46
+ options?: Core.RequestOptions,
47
+ ): Core.APIPromise<BillingConfigRetrieveResponse> {
48
+ return this._client.get(`/customers/${customerId}/billing-config/${billingProviderType}`, options);
49
+ }
50
+
51
+ /**
52
+ * Delete the billing configuration for a given customer. Note: this is unsupported
53
+ * for Azure and AWS Marketplace customers.
54
+ */
55
+ delete(
56
+ customerId: string,
57
+ billingProviderType:
58
+ | 'aws_marketplace'
59
+ | 'stripe'
60
+ | 'netsuite'
61
+ | 'custom'
62
+ | 'azure_marketplace'
63
+ | 'quickbooks_online'
64
+ | 'workday'
65
+ | 'gcp_marketplace',
66
+ options?: Core.RequestOptions,
67
+ ): Core.APIPromise<void> {
68
+ return this._client.delete(`/customers/${customerId}/billing-config/${billingProviderType}`, {
69
+ ...options,
70
+ headers: { Accept: '*/*', ...options?.headers },
71
+ });
72
+ }
73
+ }
74
+
75
+ export interface BillingConfigRetrieveResponse {
76
+ data: BillingConfigRetrieveResponse.Data;
77
+ }
78
+
79
+ export namespace BillingConfigRetrieveResponse {
80
+ export interface Data {
81
+ /**
82
+ * Contract expiration date for the customer. The expected format is RFC 3339 and
83
+ * can be retrieved from AWS's GetEntitlements API. (See
84
+ * https://docs.aws.amazon.com/marketplaceentitlement/latest/APIReference/API_GetEntitlements.html.)
85
+ */
86
+ aws_expiration_date?: string;
87
+
88
+ aws_product_code?: string;
89
+
90
+ aws_region?:
91
+ | 'af-south-1'
92
+ | 'ap-east-1'
93
+ | 'ap-northeast-1'
94
+ | 'ap-northeast-2'
95
+ | 'ap-northeast-3'
96
+ | 'ap-south-1'
97
+ | 'ap-southeast-1'
98
+ | 'ap-southeast-2'
99
+ | 'ca-central-1'
100
+ | 'cn-north-1'
101
+ | 'cn-northwest-1'
102
+ | 'eu-central-1'
103
+ | 'eu-north-1'
104
+ | 'eu-south-1'
105
+ | 'eu-west-1'
106
+ | 'eu-west-2'
107
+ | 'eu-west-3'
108
+ | 'me-south-1'
109
+ | 'sa-east-1'
110
+ | 'us-east-1'
111
+ | 'us-east-2'
112
+ | 'us-gov-east-1'
113
+ | 'us-gov-west-1'
114
+ | 'us-west-1'
115
+ | 'us-west-2';
116
+
117
+ /**
118
+ * Subscription term start/end date for the customer. The expected format is RFC
119
+ * 3339 and can be retrieved from Azure's Get Subscription API. (See
120
+ * https://learn.microsoft.com/en-us/partner-center/marketplace/partner-center-portal/pc-saas-fulfillment-subscription-api#get-subscription.)
121
+ */
122
+ azure_expiration_date?: string;
123
+
124
+ azure_plan_id?: string;
125
+
126
+ /**
127
+ * Subscription term start/end date for the customer. The expected format is RFC
128
+ * 3339 and can be retrieved from Azure's Get Subscription API. (See
129
+ * https://learn.microsoft.com/en-us/partner-center/marketplace/partner-center-portal/pc-saas-fulfillment-subscription-api#get-subscription.)
130
+ */
131
+ azure_start_date?: string;
132
+
133
+ azure_subscription_status?: 'Subscribed' | 'Unsubscribed' | 'Suspended' | 'PendingFulfillmentStart';
134
+
135
+ billing_provider_customer_id?: string;
136
+
137
+ stripe_collection_method?: 'charge_automatically' | 'send_invoice';
138
+ }
139
+ }
140
+
141
+ export interface BillingConfigCreateParams {
142
+ /**
143
+ * The customer ID in the billing provider's system. For Azure, this is the
144
+ * subscription ID.
145
+ */
146
+ billing_provider_customer_id: string;
147
+
148
+ aws_product_code?: string;
149
+
150
+ aws_region?:
151
+ | 'af-south-1'
152
+ | 'ap-east-1'
153
+ | 'ap-northeast-1'
154
+ | 'ap-northeast-2'
155
+ | 'ap-northeast-3'
156
+ | 'ap-south-1'
157
+ | 'ap-southeast-1'
158
+ | 'ap-southeast-2'
159
+ | 'ca-central-1'
160
+ | 'cn-north-1'
161
+ | 'cn-northwest-1'
162
+ | 'eu-central-1'
163
+ | 'eu-north-1'
164
+ | 'eu-south-1'
165
+ | 'eu-west-1'
166
+ | 'eu-west-2'
167
+ | 'eu-west-3'
168
+ | 'me-south-1'
169
+ | 'sa-east-1'
170
+ | 'us-east-1'
171
+ | 'us-east-2'
172
+ | 'us-gov-east-1'
173
+ | 'us-gov-west-1'
174
+ | 'us-west-1'
175
+ | 'us-west-2';
176
+
177
+ stripe_collection_method?: 'charge_automatically' | 'send_invoice';
178
+ }
179
+
180
+ export namespace BillingConfig {
181
+ export import BillingConfigRetrieveResponse = BillingConfigAPI.BillingConfigRetrieveResponse;
182
+ export import BillingConfigCreateParams = BillingConfigAPI.BillingConfigCreateParams;
183
+ }