@scaleway/sdk 2.10.0 → 2.11.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.
- package/dist/api/billing/index.js +2 -0
- package/dist/api/billing/v2beta1/api.gen.js +103 -0
- package/dist/api/billing/v2beta1/index.gen.js +4 -0
- package/dist/api/billing/v2beta1/marshalling.gen.js +87 -0
- package/dist/api/rdb/v1/marshalling.gen.js +1 -0
- package/dist/api/tem/v1alpha1/marshalling.gen.js +5 -0
- package/dist/index.cjs +251 -57
- package/dist/index.d.ts +399 -102
- package/dist/scw/constants.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { API as API$1 } from '../../../scw/api.js';
|
|
2
|
+
import { urlParams, resolveOneOf, validatePathParam } from '../../../helpers/marshalling.js';
|
|
3
|
+
import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
|
|
4
|
+
import { unmarshalListConsumptionsResponse, unmarshalListTaxesResponse, unmarshalListInvoicesResponse, unmarshalInvoice } from './marshalling.gen.js';
|
|
5
|
+
|
|
6
|
+
// This file was automatically generated. DO NOT EDIT.
|
|
7
|
+
// If you have any remark or suggestion do not hesitate to open an issue.
|
|
8
|
+
/**
|
|
9
|
+
* Billing API.
|
|
10
|
+
*
|
|
11
|
+
* This API allows you to query your consumption.
|
|
12
|
+
*/
|
|
13
|
+
class API extends API$1 {
|
|
14
|
+
pageOfListConsumptions = (request = {}) => this.client.fetch({
|
|
15
|
+
method: 'GET',
|
|
16
|
+
path: `/billing/v2beta1/consumptions`,
|
|
17
|
+
urlParams: urlParams(['billing_period', request.billingPeriod], ['category_name', request.categoryName], ['order_by', request.orderBy], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize], ...Object.entries(resolveOneOf([{
|
|
18
|
+
default: this.client.settings.defaultOrganizationId,
|
|
19
|
+
param: 'organization_id',
|
|
20
|
+
value: request.organizationId
|
|
21
|
+
}, {
|
|
22
|
+
default: this.client.settings.defaultProjectId,
|
|
23
|
+
param: 'project_id',
|
|
24
|
+
value: request.projectId
|
|
25
|
+
}])))
|
|
26
|
+
}, unmarshalListConsumptionsResponse);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get monthly consumption. Consumption allows you to retrieve your past or
|
|
30
|
+
* current consumption cost, by project or category.
|
|
31
|
+
*
|
|
32
|
+
* @param request - The request {@link ListConsumptionsRequest}
|
|
33
|
+
* @returns A Promise of ListConsumptionsResponse
|
|
34
|
+
*/
|
|
35
|
+
listConsumptions = (request = {}) => enrichForPagination('consumptions', this.pageOfListConsumptions, request);
|
|
36
|
+
pageOfListTaxes = (request = {}) => this.client.fetch({
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: `/billing/v2beta1/taxes`,
|
|
39
|
+
urlParams: urlParams(['billing_period', request.billingPeriod], ['order_by', request.orderBy], ['organization_id', request.organizationId ?? this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize])
|
|
40
|
+
}, unmarshalListTaxesResponse);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get monthly consumption taxes. Consumption Tax allows you to retrieve your
|
|
44
|
+
* past or current tax charges, by project or category.
|
|
45
|
+
*
|
|
46
|
+
* @param request - The request {@link ListTaxesRequest}
|
|
47
|
+
* @returns A Promise of ListTaxesResponse
|
|
48
|
+
*/
|
|
49
|
+
listTaxes = (request = {}) => enrichForPagination('taxes', this.pageOfListTaxes, request);
|
|
50
|
+
pageOfListInvoices = (request = {}) => this.client.fetch({
|
|
51
|
+
method: 'GET',
|
|
52
|
+
path: `/billing/v2beta1/invoices`,
|
|
53
|
+
urlParams: urlParams(['billing_period_start_after', request.billingPeriodStartAfter], ['billing_period_start_before', request.billingPeriodStartBefore], ['invoice_type', request.invoiceType], ['order_by', request.orderBy], ['organization_id', request.organizationId], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize])
|
|
54
|
+
}, unmarshalListInvoicesResponse);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* List invoices. List all your invoices, filtering by `start_date` and
|
|
58
|
+
* `invoice_type`. Each invoice has its own ID.
|
|
59
|
+
*
|
|
60
|
+
* @param request - The request {@link ListInvoicesRequest}
|
|
61
|
+
* @returns A Promise of ListInvoicesResponse
|
|
62
|
+
*/
|
|
63
|
+
listInvoices = (request = {}) => enrichForPagination('invoices', this.pageOfListInvoices, request);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Export invoices. Export invoices in a CSV file.
|
|
67
|
+
*
|
|
68
|
+
* @param request - The request {@link ExportInvoicesRequest}
|
|
69
|
+
* @returns A Promise of Blob
|
|
70
|
+
*/
|
|
71
|
+
exportInvoices = (request = {}) => this.client.fetch({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
path: `/billing/v2beta1/export-invoices`,
|
|
74
|
+
urlParams: urlParams(['dl', 1], ['billing_period_start_after', request.billingPeriodStartAfter], ['billing_period_start_before', request.billingPeriodStartBefore], ['file_type', request.fileType], ['invoice_type', request.invoiceType], ['order_by', request.orderBy], ['organization_id', request.organizationId], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize]),
|
|
75
|
+
responseType: 'blob'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get an invoice. Get a specific invoice, specified by its ID.
|
|
80
|
+
*
|
|
81
|
+
* @param request - The request {@link GetInvoiceRequest}
|
|
82
|
+
* @returns A Promise of Invoice
|
|
83
|
+
*/
|
|
84
|
+
getInvoice = request => this.client.fetch({
|
|
85
|
+
method: 'GET',
|
|
86
|
+
path: `/billing/v2beta1/invoices/${validatePathParam('invoiceId', request.invoiceId)}`
|
|
87
|
+
}, unmarshalInvoice);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Download an invoice. Download a specific invoice, specified by its ID.
|
|
91
|
+
*
|
|
92
|
+
* @param request - The request {@link DownloadInvoiceRequest}
|
|
93
|
+
* @returns A Promise of Blob
|
|
94
|
+
*/
|
|
95
|
+
downloadInvoice = request => this.client.fetch({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
path: `/billing/v2beta1/invoices/${validatePathParam('invoiceId', request.invoiceId)}/download`,
|
|
98
|
+
urlParams: urlParams(['dl', 1], ['file_type', request.fileType]),
|
|
99
|
+
responseType: 'blob'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { API };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isJSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { unmarshalMoney } from '../../../scw/custom-marshalling.js';
|
|
3
|
+
import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
|
|
4
|
+
|
|
5
|
+
// This file was automatically generated. DO NOT EDIT.
|
|
6
|
+
// If you have any remark or suggestion do not hesitate to open an issue.
|
|
7
|
+
const unmarshalInvoice = data => {
|
|
8
|
+
if (!isJSONObject(data)) {
|
|
9
|
+
throw new TypeError(`Unmarshalling the type 'Invoice' failed as data isn't a dictionary.`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
billingPeriod: unmarshalDate(data.billing_period),
|
|
13
|
+
customerName: data.customer_name,
|
|
14
|
+
dueDate: unmarshalDate(data.due_date),
|
|
15
|
+
id: data.id,
|
|
16
|
+
issuedDate: unmarshalDate(data.issued_date),
|
|
17
|
+
number: data.number,
|
|
18
|
+
organizationId: data.organization_id,
|
|
19
|
+
organizationName: data.organization_name,
|
|
20
|
+
sellerName: data.seller_name,
|
|
21
|
+
startDate: unmarshalDate(data.start_date),
|
|
22
|
+
state: data.state,
|
|
23
|
+
stopDate: unmarshalDate(data.stop_date),
|
|
24
|
+
totalDiscount: data.total_discount ? unmarshalMoney(data.total_discount) : undefined,
|
|
25
|
+
totalTax: data.total_tax ? unmarshalMoney(data.total_tax) : undefined,
|
|
26
|
+
totalTaxed: data.total_taxed ? unmarshalMoney(data.total_taxed) : undefined,
|
|
27
|
+
totalUndiscount: data.total_undiscount ? unmarshalMoney(data.total_undiscount) : undefined,
|
|
28
|
+
totalUntaxed: data.total_untaxed ? unmarshalMoney(data.total_untaxed) : undefined,
|
|
29
|
+
type: data.type
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const unmarshalListConsumptionsResponseConsumption = data => {
|
|
33
|
+
if (!isJSONObject(data)) {
|
|
34
|
+
throw new TypeError(`Unmarshalling the type 'ListConsumptionsResponseConsumption' failed as data isn't a dictionary.`);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
categoryName: data.category_name,
|
|
38
|
+
productName: data.product_name,
|
|
39
|
+
projectId: data.project_id,
|
|
40
|
+
resourceName: data.resource_name,
|
|
41
|
+
sku: data.sku,
|
|
42
|
+
value: data.value ? unmarshalMoney(data.value) : undefined
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const unmarshalListConsumptionsResponse = data => {
|
|
46
|
+
if (!isJSONObject(data)) {
|
|
47
|
+
throw new TypeError(`Unmarshalling the type 'ListConsumptionsResponse' failed as data isn't a dictionary.`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
consumptions: unmarshalArrayOfObject(data.consumptions, unmarshalListConsumptionsResponseConsumption),
|
|
51
|
+
totalCount: data.total_count,
|
|
52
|
+
totalDiscountUntaxedValue: data.total_discount_untaxed_value,
|
|
53
|
+
updatedAt: unmarshalDate(data.updated_at)
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const unmarshalListInvoicesResponse = data => {
|
|
57
|
+
if (!isJSONObject(data)) {
|
|
58
|
+
throw new TypeError(`Unmarshalling the type 'ListInvoicesResponse' failed as data isn't a dictionary.`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
invoices: unmarshalArrayOfObject(data.invoices, unmarshalInvoice),
|
|
62
|
+
totalCount: data.total_count
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const unmarshalListTaxesResponseTax = data => {
|
|
66
|
+
if (!isJSONObject(data)) {
|
|
67
|
+
throw new TypeError(`Unmarshalling the type 'ListTaxesResponseTax' failed as data isn't a dictionary.`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
currency: data.currency,
|
|
71
|
+
description: data.description,
|
|
72
|
+
rate: data.rate,
|
|
73
|
+
totalTaxValue: data.total_tax_value
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const unmarshalListTaxesResponse = data => {
|
|
77
|
+
if (!isJSONObject(data)) {
|
|
78
|
+
throw new TypeError(`Unmarshalling the type 'ListTaxesResponse' failed as data isn't a dictionary.`);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
taxes: unmarshalArrayOfObject(data.taxes, unmarshalListTaxesResponseTax),
|
|
82
|
+
totalCount: data.total_count,
|
|
83
|
+
updatedAt: unmarshalDate(data.updated_at)
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export { unmarshalInvoice, unmarshalListConsumptionsResponse, unmarshalListInvoicesResponse, unmarshalListTaxesResponse };
|
|
@@ -165,7 +165,12 @@ const marshalCreateEmailRequestAttachment = (request, defaults) => ({
|
|
|
165
165
|
name: request.name,
|
|
166
166
|
type: request.type
|
|
167
167
|
});
|
|
168
|
+
const marshalCreateEmailRequestHeader = (request, defaults) => ({
|
|
169
|
+
key: request.key,
|
|
170
|
+
value: request.value
|
|
171
|
+
});
|
|
168
172
|
const marshalCreateEmailRequest = (request, defaults) => ({
|
|
173
|
+
additional_headers: request.additionalHeaders !== undefined ? request.additionalHeaders.map(elt => marshalCreateEmailRequestHeader(elt)) : undefined,
|
|
169
174
|
attachments: request.attachments !== undefined ? request.attachments.map(elt => marshalCreateEmailRequestAttachment(elt)) : undefined,
|
|
170
175
|
bcc: request.bcc !== undefined ? request.bcc.map(elt => marshalCreateEmailRequestAddress(elt)) : undefined,
|
|
171
176
|
cc: request.cc !== undefined ? request.cc.map(elt => marshalCreateEmailRequestAddress(elt)) : undefined,
|