@scaleway/sdk-environmental-footprint 1.1.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/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2019 Scaleway.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ https://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index_gen = require("./v1alpha1/index.gen.cjs");
4
+ exports.EnvironmentalFootprintv1alpha1 = index_gen;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This file is automatically generated
3
+ * PLEASE DO NOT EDIT HERE
4
+ */
5
+ export * as EnvironmentalFootprintv1alpha1 from './v1alpha1/index.gen.js';
@@ -0,0 +1,4 @@
1
+ import * as index_gen from "./v1alpha1/index.gen.js";
2
+ export {
3
+ index_gen as EnvironmentalFootprintv1alpha1
4
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const marshalling_gen = require("./marshalling.gen.cjs");
5
+ const jsonContentHeaders = {
6
+ "Content-Type": "application/json; charset=utf-8"
7
+ };
8
+ class UserAPI extends sdkClient.API {
9
+ /**
10
+ * Get available impact reports. Returns a list of dates of available impact reports.
11
+ *
12
+ * @param request - The request {@link UserApiGetImpactReportAvailabilityRequest}
13
+ * @returns A Promise of ImpactReportAvailability
14
+ */
15
+ getImpactReportAvailability = (request = {}) => this.client.fetch(
16
+ {
17
+ method: "GET",
18
+ path: `/environmental-footprint/v1alpha1/reports/availability`,
19
+ urlParams: sdkClient.urlParams(
20
+ ["end_date", request.endDate],
21
+ [
22
+ "organization_id",
23
+ request.organizationId ?? this.client.settings.defaultOrganizationId
24
+ ],
25
+ ["start_date", request.startDate]
26
+ )
27
+ },
28
+ marshalling_gen.unmarshalImpactReportAvailability
29
+ );
30
+ /**
31
+ * Download PDF impact report. Download a Scaleway impact PDF report with detailed impact data for your Scaleway projects.
32
+ *
33
+ * @param request - The request {@link UserApiDownloadImpactReportRequest}
34
+ * @returns A Promise of Blob
35
+ */
36
+ downloadImpactReport = (request = {}) => this.client.fetch({
37
+ body: JSON.stringify(
38
+ marshalling_gen.marshalUserApiDownloadImpactReportRequest(
39
+ request,
40
+ this.client.settings
41
+ )
42
+ ),
43
+ headers: jsonContentHeaders,
44
+ method: "POST",
45
+ path: `/environmental-footprint/v1alpha1/reports/download`,
46
+ urlParams: sdkClient.urlParams(
47
+ ["dl", 1],
48
+ ["date", request.date],
49
+ [
50
+ "organization_id",
51
+ request.organizationId ?? this.client.settings.defaultOrganizationId
52
+ ],
53
+ ["type", request.type]
54
+ ),
55
+ responseType: "blob"
56
+ });
57
+ /**
58
+ * Retrieve detailed impact data. Retrieve detailed impact data for your Scaleway projects within a specified date range. Filter by project ID, region, zone, service category, and/or product category.
59
+ *
60
+ * @param request - The request {@link UserApiGetImpactDataRequest}
61
+ * @returns A Promise of ImpactDataResponse
62
+ */
63
+ getImpactData = (request = {}) => this.client.fetch(
64
+ {
65
+ method: "GET",
66
+ path: `/environmental-footprint/v1alpha1/data/query`,
67
+ urlParams: sdkClient.urlParams(
68
+ ["end_date", request.endDate],
69
+ [
70
+ "organization_id",
71
+ request.organizationId ?? this.client.settings.defaultOrganizationId
72
+ ],
73
+ ["product_categories", request.productCategories],
74
+ ["project_ids", request.projectIds],
75
+ ["regions", request.regions],
76
+ ["service_categories", request.serviceCategories],
77
+ ["start_date", request.startDate],
78
+ ["zones", request.zones]
79
+ )
80
+ },
81
+ marshalling_gen.unmarshalImpactDataResponse
82
+ );
83
+ }
84
+ exports.UserAPI = UserAPI;
@@ -0,0 +1,30 @@
1
+ import { API as ParentAPI } from '@scaleway/sdk-client';
2
+ import type { ImpactDataResponse, ImpactReportAvailability, UserApiDownloadImpactReportRequest, UserApiGetImpactDataRequest, UserApiGetImpactReportAvailabilityRequest } from './types.gen.js';
3
+ /**
4
+ * Environmental Footprint API.
5
+
6
+ Access and download impact reports and impact data for your Scaleway projects. Our API provides key metrics such as estimated carbon emissions and water usage to help monitor your environmental footprint.
7
+ */
8
+ export declare class UserAPI extends ParentAPI {
9
+ /**
10
+ * Get available impact reports. Returns a list of dates of available impact reports.
11
+ *
12
+ * @param request - The request {@link UserApiGetImpactReportAvailabilityRequest}
13
+ * @returns A Promise of ImpactReportAvailability
14
+ */
15
+ getImpactReportAvailability: (request?: Readonly<UserApiGetImpactReportAvailabilityRequest>) => Promise<ImpactReportAvailability>;
16
+ /**
17
+ * Download PDF impact report. Download a Scaleway impact PDF report with detailed impact data for your Scaleway projects.
18
+ *
19
+ * @param request - The request {@link UserApiDownloadImpactReportRequest}
20
+ * @returns A Promise of Blob
21
+ */
22
+ downloadImpactReport: (request?: Readonly<UserApiDownloadImpactReportRequest>) => Promise<Blob>;
23
+ /**
24
+ * Retrieve detailed impact data. Retrieve detailed impact data for your Scaleway projects within a specified date range. Filter by project ID, region, zone, service category, and/or product category.
25
+ *
26
+ * @param request - The request {@link UserApiGetImpactDataRequest}
27
+ * @returns A Promise of ImpactDataResponse
28
+ */
29
+ getImpactData: (request?: Readonly<UserApiGetImpactDataRequest>) => Promise<ImpactDataResponse>;
30
+ }
@@ -0,0 +1,84 @@
1
+ import { API, urlParams } from "@scaleway/sdk-client";
2
+ import { unmarshalImpactReportAvailability, marshalUserApiDownloadImpactReportRequest, unmarshalImpactDataResponse } from "./marshalling.gen.js";
3
+ const jsonContentHeaders = {
4
+ "Content-Type": "application/json; charset=utf-8"
5
+ };
6
+ class UserAPI extends API {
7
+ /**
8
+ * Get available impact reports. Returns a list of dates of available impact reports.
9
+ *
10
+ * @param request - The request {@link UserApiGetImpactReportAvailabilityRequest}
11
+ * @returns A Promise of ImpactReportAvailability
12
+ */
13
+ getImpactReportAvailability = (request = {}) => this.client.fetch(
14
+ {
15
+ method: "GET",
16
+ path: `/environmental-footprint/v1alpha1/reports/availability`,
17
+ urlParams: urlParams(
18
+ ["end_date", request.endDate],
19
+ [
20
+ "organization_id",
21
+ request.organizationId ?? this.client.settings.defaultOrganizationId
22
+ ],
23
+ ["start_date", request.startDate]
24
+ )
25
+ },
26
+ unmarshalImpactReportAvailability
27
+ );
28
+ /**
29
+ * Download PDF impact report. Download a Scaleway impact PDF report with detailed impact data for your Scaleway projects.
30
+ *
31
+ * @param request - The request {@link UserApiDownloadImpactReportRequest}
32
+ * @returns A Promise of Blob
33
+ */
34
+ downloadImpactReport = (request = {}) => this.client.fetch({
35
+ body: JSON.stringify(
36
+ marshalUserApiDownloadImpactReportRequest(
37
+ request,
38
+ this.client.settings
39
+ )
40
+ ),
41
+ headers: jsonContentHeaders,
42
+ method: "POST",
43
+ path: `/environmental-footprint/v1alpha1/reports/download`,
44
+ urlParams: urlParams(
45
+ ["dl", 1],
46
+ ["date", request.date],
47
+ [
48
+ "organization_id",
49
+ request.organizationId ?? this.client.settings.defaultOrganizationId
50
+ ],
51
+ ["type", request.type]
52
+ ),
53
+ responseType: "blob"
54
+ });
55
+ /**
56
+ * Retrieve detailed impact data. Retrieve detailed impact data for your Scaleway projects within a specified date range. Filter by project ID, region, zone, service category, and/or product category.
57
+ *
58
+ * @param request - The request {@link UserApiGetImpactDataRequest}
59
+ * @returns A Promise of ImpactDataResponse
60
+ */
61
+ getImpactData = (request = {}) => this.client.fetch(
62
+ {
63
+ method: "GET",
64
+ path: `/environmental-footprint/v1alpha1/data/query`,
65
+ urlParams: urlParams(
66
+ ["end_date", request.endDate],
67
+ [
68
+ "organization_id",
69
+ request.organizationId ?? this.client.settings.defaultOrganizationId
70
+ ],
71
+ ["product_categories", request.productCategories],
72
+ ["project_ids", request.projectIds],
73
+ ["regions", request.regions],
74
+ ["service_categories", request.serviceCategories],
75
+ ["start_date", request.startDate],
76
+ ["zones", request.zones]
77
+ )
78
+ },
79
+ unmarshalImpactDataResponse
80
+ );
81
+ }
82
+ export {
83
+ UserAPI
84
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api_gen = require("./api.gen.cjs");
4
+ const marshalling_gen = require("./marshalling.gen.cjs");
5
+ exports.UserAPI = api_gen.UserAPI;
6
+ exports.marshalUserApiDownloadImpactReportRequest = marshalling_gen.marshalUserApiDownloadImpactReportRequest;
7
+ exports.unmarshalImpactDataResponse = marshalling_gen.unmarshalImpactDataResponse;
8
+ exports.unmarshalImpactReportAvailability = marshalling_gen.unmarshalImpactReportAvailability;
@@ -0,0 +1,3 @@
1
+ export { UserAPI } from './api.gen.js';
2
+ export * from './marshalling.gen.js';
3
+ export type { Impact, ImpactDataResponse, ImpactReportAvailability, ProductCategory, ProjectImpact, RegionImpact, ReportType, ServiceCategory, SkuImpact, UserApiDownloadImpactReportRequest, UserApiGetImpactDataRequest, UserApiGetImpactReportAvailabilityRequest, ZoneImpact, } from './types.gen.js';
@@ -0,0 +1,8 @@
1
+ import { UserAPI } from "./api.gen.js";
2
+ import { marshalUserApiDownloadImpactReportRequest, unmarshalImpactDataResponse, unmarshalImpactReportAvailability } from "./marshalling.gen.js";
3
+ export {
4
+ UserAPI,
5
+ marshalUserApiDownloadImpactReportRequest,
6
+ unmarshalImpactDataResponse,
7
+ unmarshalImpactReportAvailability
8
+ };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const unmarshalImpact = (data) => {
5
+ if (!sdkClient.isJSONObject(data)) {
6
+ throw new TypeError(
7
+ `Unmarshalling the type 'Impact' failed as data isn't a dictionary.`
8
+ );
9
+ }
10
+ return {
11
+ kgCo2Equivalent: data.kg_co2_equivalent,
12
+ m3WaterUsage: data.m3_water_usage
13
+ };
14
+ };
15
+ const unmarshalSkuImpact = (data) => {
16
+ if (!sdkClient.isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'SkuImpact' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {
22
+ productCategory: data.product_category,
23
+ serviceCategory: data.service_category,
24
+ sku: data.sku,
25
+ totalSkuImpact: data.total_sku_impact ? unmarshalImpact(data.total_sku_impact) : void 0
26
+ };
27
+ };
28
+ const unmarshalZoneImpact = (data) => {
29
+ if (!sdkClient.isJSONObject(data)) {
30
+ throw new TypeError(
31
+ `Unmarshalling the type 'ZoneImpact' failed as data isn't a dictionary.`
32
+ );
33
+ }
34
+ return {
35
+ skus: sdkClient.unmarshalArrayOfObject(data.skus, unmarshalSkuImpact),
36
+ totalZoneImpact: data.total_zone_impact ? unmarshalImpact(data.total_zone_impact) : void 0,
37
+ zone: data.zone
38
+ };
39
+ };
40
+ const unmarshalRegionImpact = (data) => {
41
+ if (!sdkClient.isJSONObject(data)) {
42
+ throw new TypeError(
43
+ `Unmarshalling the type 'RegionImpact' failed as data isn't a dictionary.`
44
+ );
45
+ }
46
+ return {
47
+ region: data.region,
48
+ totalRegionImpact: data.total_region_impact ? unmarshalImpact(data.total_region_impact) : void 0,
49
+ zones: sdkClient.unmarshalArrayOfObject(data.zones, unmarshalZoneImpact)
50
+ };
51
+ };
52
+ const unmarshalProjectImpact = (data) => {
53
+ if (!sdkClient.isJSONObject(data)) {
54
+ throw new TypeError(
55
+ `Unmarshalling the type 'ProjectImpact' failed as data isn't a dictionary.`
56
+ );
57
+ }
58
+ return {
59
+ projectId: data.project_id,
60
+ regions: sdkClient.unmarshalArrayOfObject(data.regions, unmarshalRegionImpact),
61
+ totalProjectImpact: data.total_project_impact ? unmarshalImpact(data.total_project_impact) : void 0
62
+ };
63
+ };
64
+ const unmarshalImpactDataResponse = (data) => {
65
+ if (!sdkClient.isJSONObject(data)) {
66
+ throw new TypeError(
67
+ `Unmarshalling the type 'ImpactDataResponse' failed as data isn't a dictionary.`
68
+ );
69
+ }
70
+ return {
71
+ endDate: sdkClient.unmarshalDate(data.end_date),
72
+ projects: sdkClient.unmarshalArrayOfObject(data.projects, unmarshalProjectImpact),
73
+ startDate: sdkClient.unmarshalDate(data.start_date),
74
+ totalImpact: data.total_impact ? unmarshalImpact(data.total_impact) : void 0
75
+ };
76
+ };
77
+ const unmarshalImpactReportAvailability = (data) => {
78
+ if (!sdkClient.isJSONObject(data)) {
79
+ throw new TypeError(
80
+ `Unmarshalling the type 'ImpactReportAvailability' failed as data isn't a dictionary.`
81
+ );
82
+ }
83
+ return {
84
+ monthSummaryReports: sdkClient.unmarshalArrayOfObject(
85
+ data.month_summary_reports,
86
+ sdkClient.unmarshalDate
87
+ )
88
+ };
89
+ };
90
+ const marshalUserApiDownloadImpactReportRequest = (request, defaults) => ({
91
+ date: request.date,
92
+ organization_id: request.organizationId ?? defaults.defaultOrganizationId,
93
+ type: request.type
94
+ });
95
+ exports.marshalUserApiDownloadImpactReportRequest = marshalUserApiDownloadImpactReportRequest;
96
+ exports.unmarshalImpactDataResponse = unmarshalImpactDataResponse;
97
+ exports.unmarshalImpactReportAvailability = unmarshalImpactReportAvailability;
@@ -0,0 +1,5 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { ImpactDataResponse, ImpactReportAvailability, UserApiDownloadImpactReportRequest } from './types.gen.js';
3
+ export declare const unmarshalImpactDataResponse: (data: unknown) => ImpactDataResponse;
4
+ export declare const unmarshalImpactReportAvailability: (data: unknown) => ImpactReportAvailability;
5
+ export declare const marshalUserApiDownloadImpactReportRequest: (request: UserApiDownloadImpactReportRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -0,0 +1,97 @@
1
+ import { isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ const unmarshalImpact = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'Impact' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ kgCo2Equivalent: data.kg_co2_equivalent,
10
+ m3WaterUsage: data.m3_water_usage
11
+ };
12
+ };
13
+ const unmarshalSkuImpact = (data) => {
14
+ if (!isJSONObject(data)) {
15
+ throw new TypeError(
16
+ `Unmarshalling the type 'SkuImpact' failed as data isn't a dictionary.`
17
+ );
18
+ }
19
+ return {
20
+ productCategory: data.product_category,
21
+ serviceCategory: data.service_category,
22
+ sku: data.sku,
23
+ totalSkuImpact: data.total_sku_impact ? unmarshalImpact(data.total_sku_impact) : void 0
24
+ };
25
+ };
26
+ const unmarshalZoneImpact = (data) => {
27
+ if (!isJSONObject(data)) {
28
+ throw new TypeError(
29
+ `Unmarshalling the type 'ZoneImpact' failed as data isn't a dictionary.`
30
+ );
31
+ }
32
+ return {
33
+ skus: unmarshalArrayOfObject(data.skus, unmarshalSkuImpact),
34
+ totalZoneImpact: data.total_zone_impact ? unmarshalImpact(data.total_zone_impact) : void 0,
35
+ zone: data.zone
36
+ };
37
+ };
38
+ const unmarshalRegionImpact = (data) => {
39
+ if (!isJSONObject(data)) {
40
+ throw new TypeError(
41
+ `Unmarshalling the type 'RegionImpact' failed as data isn't a dictionary.`
42
+ );
43
+ }
44
+ return {
45
+ region: data.region,
46
+ totalRegionImpact: data.total_region_impact ? unmarshalImpact(data.total_region_impact) : void 0,
47
+ zones: unmarshalArrayOfObject(data.zones, unmarshalZoneImpact)
48
+ };
49
+ };
50
+ const unmarshalProjectImpact = (data) => {
51
+ if (!isJSONObject(data)) {
52
+ throw new TypeError(
53
+ `Unmarshalling the type 'ProjectImpact' failed as data isn't a dictionary.`
54
+ );
55
+ }
56
+ return {
57
+ projectId: data.project_id,
58
+ regions: unmarshalArrayOfObject(data.regions, unmarshalRegionImpact),
59
+ totalProjectImpact: data.total_project_impact ? unmarshalImpact(data.total_project_impact) : void 0
60
+ };
61
+ };
62
+ const unmarshalImpactDataResponse = (data) => {
63
+ if (!isJSONObject(data)) {
64
+ throw new TypeError(
65
+ `Unmarshalling the type 'ImpactDataResponse' failed as data isn't a dictionary.`
66
+ );
67
+ }
68
+ return {
69
+ endDate: unmarshalDate(data.end_date),
70
+ projects: unmarshalArrayOfObject(data.projects, unmarshalProjectImpact),
71
+ startDate: unmarshalDate(data.start_date),
72
+ totalImpact: data.total_impact ? unmarshalImpact(data.total_impact) : void 0
73
+ };
74
+ };
75
+ const unmarshalImpactReportAvailability = (data) => {
76
+ if (!isJSONObject(data)) {
77
+ throw new TypeError(
78
+ `Unmarshalling the type 'ImpactReportAvailability' failed as data isn't a dictionary.`
79
+ );
80
+ }
81
+ return {
82
+ monthSummaryReports: unmarshalArrayOfObject(
83
+ data.month_summary_reports,
84
+ unmarshalDate
85
+ )
86
+ };
87
+ };
88
+ const marshalUserApiDownloadImpactReportRequest = (request, defaults) => ({
89
+ date: request.date,
90
+ organization_id: request.organizationId ?? defaults.defaultOrganizationId,
91
+ type: request.type
92
+ });
93
+ export {
94
+ marshalUserApiDownloadImpactReportRequest,
95
+ unmarshalImpactDataResponse,
96
+ unmarshalImpactReportAvailability
97
+ };
@@ -0,0 +1,160 @@
1
+ import type { Region as ScwRegion, Zone as ScwZone } from '@scaleway/sdk-client';
2
+ export type ProductCategory = 'unknown_product_category' | 'apple_silicon' | 'block_storage' | 'dedibox' | 'elastic_metal' | 'instances' | 'object_storage';
3
+ export type ReportType = 'unknown_report_type' | 'monthly' | 'yearly';
4
+ export type ServiceCategory = 'unknown_service_category' | 'baremetal' | 'compute' | 'storage';
5
+ export interface Impact {
6
+ /**
7
+ * The estimated carbon emissions in kilograms of CO₂ equivalent (kgCO₂e).
8
+ */
9
+ kgCo2Equivalent: number;
10
+ /**
11
+ * The estimated water consumption in cubic meters (m³).
12
+ */
13
+ m3WaterUsage: number;
14
+ }
15
+ export interface SkuImpact {
16
+ /**
17
+ * Unique ID of the combination of product, region and zone.
18
+ */
19
+ sku: string;
20
+ /**
21
+ * The total estimated impact for this SKU during the given period.
22
+ */
23
+ totalSkuImpact?: Impact;
24
+ /**
25
+ * The service category associated with this SKU.
26
+ */
27
+ serviceCategory: ServiceCategory;
28
+ /**
29
+ * The product category associated with this SKU.
30
+ */
31
+ productCategory: ProductCategory;
32
+ }
33
+ export interface ZoneImpact {
34
+ /**
35
+ * ID of the zone.
36
+ */
37
+ zone: ScwZone;
38
+ /**
39
+ * The total estimated impact for this zone across all given service categories, and product categories during the given period.
40
+ */
41
+ totalZoneImpact?: Impact;
42
+ /**
43
+ * List of estimated impact values per SKU.
44
+ */
45
+ skus: SkuImpact[];
46
+ }
47
+ export interface RegionImpact {
48
+ /**
49
+ * ID of the region.
50
+ */
51
+ region: ScwRegion;
52
+ /**
53
+ * The total estimated impact for this region across all given zones, service categories, and product categories during the given period.
54
+ */
55
+ totalRegionImpact?: Impact;
56
+ /**
57
+ * List of estimated impact values per zone.
58
+ */
59
+ zones: ZoneImpact[];
60
+ }
61
+ export interface ProjectImpact {
62
+ /**
63
+ * ID of the project.
64
+ */
65
+ projectId: string;
66
+ /**
67
+ * The total estimated impact for this Project across all given regions, zones, service categories, and product categories during the given period.
68
+ */
69
+ totalProjectImpact?: Impact;
70
+ /**
71
+ * List of estimated impact values per region.
72
+ */
73
+ regions: RegionImpact[];
74
+ }
75
+ export interface ImpactDataResponse {
76
+ /**
77
+ * Start date of the impact data period (inclusive).
78
+ */
79
+ startDate?: Date;
80
+ /**
81
+ * End date of the impact data period (exclusive).
82
+ */
83
+ endDate?: Date;
84
+ /**
85
+ * The total estimated impact across all given Projects, regions, zones, service categories, and product categories during the given period.
86
+ */
87
+ totalImpact?: Impact;
88
+ /**
89
+ * List of estimated impact values per Project.
90
+ */
91
+ projects: ProjectImpact[];
92
+ }
93
+ export interface ImpactReportAvailability {
94
+ /**
95
+ * The list of calendar months for which impact reports are available.
96
+ */
97
+ monthSummaryReports: Date[];
98
+ }
99
+ export type UserApiDownloadImpactReportRequest = {
100
+ /**
101
+ * The UUID of the Organization for which you want to download a report.
102
+ */
103
+ organizationId?: string;
104
+ /**
105
+ * The start date of the period for which you want to download a report (ISO 8601 format, e.g. 2025-05-01T00:00:00Z).
106
+ */
107
+ date?: Date;
108
+ /**
109
+ * Type of report to download (e.g. `monthly`).
110
+ */
111
+ type?: ReportType;
112
+ };
113
+ export type UserApiGetImpactDataRequest = {
114
+ /**
115
+ * The UUID of the Organization for which you want to download a report.
116
+ */
117
+ organizationId?: string;
118
+ /**
119
+ * Start date (inclusive) of the period for which you want to retrieve impact data (ISO 8601 format, e.g. 2025-05-01T00:00:00Z).
120
+ */
121
+ startDate?: Date;
122
+ /**
123
+ * End date (exclusive) of the period for which you want to retrieve impact data (ISO 8601 format, with time in UTC, `YYYY-MM-DDTHH:MM:SSZ`). Defaults to today's date.
124
+ */
125
+ endDate?: Date;
126
+ /**
127
+ * List of regions to filter by (e.g. `fr-par`). Defaults to all regions.
128
+ */
129
+ regions?: string[];
130
+ /**
131
+ * List of zones to filter by (e.g. `fr-par-1`). Defaults to all zones.
132
+ */
133
+ zones?: string[];
134
+ /**
135
+ * List of Project IDs to filter by. Defaults to all Projects in the Organization.
136
+ */
137
+ projectIds?: string[];
138
+ /**
139
+ * List of service categories to filter by. Defaults to all service categories.
140
+ */
141
+ serviceCategories?: ServiceCategory[];
142
+ /**
143
+ * List of product categories to filter by. Defaults to all product categories.
144
+ */
145
+ productCategories?: ProductCategory[];
146
+ };
147
+ export type UserApiGetImpactReportAvailabilityRequest = {
148
+ /**
149
+ * The UUID of the Organization for which you want to download a report.
150
+ */
151
+ organizationId?: string;
152
+ /**
153
+ * Start date of the search period (ISO 8601 format, with time in UTC, `YYYY-MM-DDTHH:MM:SSZ`). The date is inclusive.
154
+ */
155
+ startDate?: Date;
156
+ /**
157
+ * End date of the search period (ISO 8601 format, with time in UTC, `YYYY-MM-DDTHH:MM:SSZ`). The date is inclusive. Defaults to today's date.
158
+ */
159
+ endDate?: Date;
160
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@scaleway/sdk-environmental-footprint",
3
+ "version": "1.1.0",
4
+ "description": "Scaleway SDK environmental-footprint",
5
+ "license": "Apache-2.0",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.gen.d.ts",
13
+ "import": "./dist/index.gen.js",
14
+ "require": "./dist/index.gen.cjs",
15
+ "default": "./dist/index.gen.js"
16
+ },
17
+ "./*": {
18
+ "types": "./dist/*/index.gen.d.ts",
19
+ "import": "./dist/*/index.gen.js",
20
+ "require": "./dist/*/index.gen.cjs",
21
+ "default": "./dist/*/index.gen.js"
22
+ }
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "directory": "packages_generated/environmental-footprint"
27
+ },
28
+ "engines": {
29
+ "node": ">=20.18.3"
30
+ },
31
+ "dependencies": {
32
+ "@scaleway/random-name": "5.1.1",
33
+ "@scaleway/sdk-std": "1.1.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@scaleway/sdk-client": "^1.3.2"
37
+ },
38
+ "devDependencies": {
39
+ "@scaleway/sdk-client": "^1.3.2"
40
+ },
41
+ "scripts": {
42
+ "package:check": "pnpm publint",
43
+ "typecheck": "tsc --noEmit",
44
+ "type:generate": "tsc --declaration -p tsconfig.build.json",
45
+ "build": "vite build --config vite.config.ts && pnpm run type:generate",
46
+ "build:profile": "npx vite-bundle-visualizer -c vite.config.ts"
47
+ }
48
+ }