@scaleway/sdk-environmental-footprint 1.2.0 → 2.2.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/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @scaleway/sdk-environmental-footprint
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@scaleway/sdk-environmental-footprint.svg)](https://www.npmjs.com/package/@scaleway/sdk-environmental-footprint)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@scaleway/sdk-environmental-footprint.svg)](https://www.npmjs.com/package/@scaleway/sdk-environmental-footprint)
5
+ [![license](https://img.shields.io/npm/l/@scaleway/sdk-environmental-footprint.svg)](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE)
6
+
7
+ Scaleway SDK for Environmental Footprint API.
8
+
9
+ > **Note**
10
+ > This is an automatically generated package that is part of the [Scaleway SDK for JavaScript](https://github.com/scaleway/scaleway-sdk-js).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @scaleway/sdk-environmental-footprint @scaleway/sdk-client
16
+ ```
17
+
18
+ or with pnpm:
19
+
20
+ ```bash
21
+ pnpm add @scaleway/sdk-environmental-footprint @scaleway/sdk-client
22
+ ```
23
+
24
+ or with yarn:
25
+
26
+ ```bash
27
+ yarn add @scaleway/sdk-environmental-footprint @scaleway/sdk-client
28
+ ```
29
+
30
+ ## Getting Started
31
+
32
+ You'll need a pair of access and secret keys to connect to Scaleway API. Please check the [documentation](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) on how to retrieve them.
33
+
34
+ ### Basic Usage
35
+
36
+ ```typescript
37
+ import { createClient } from '@scaleway/sdk-client'
38
+ import { EnvironmentalFootprint } from '@scaleway/sdk-environmental-footprint'
39
+
40
+ const client = createClient({
41
+ accessKey: 'SCWXXXXXXXXXXXXXXXXX',
42
+ secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
43
+ defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
44
+ defaultRegion: 'fr-par',
45
+ defaultZone: 'fr-par-1',
46
+ })
47
+
48
+ const api = new EnvironmentalFootprint.v1.API(client)
49
+
50
+ // Use the API
51
+ // Example: await api.listServers()
52
+ ```
53
+
54
+ ### Using Configuration Loader
55
+
56
+ For a simpler setup, you can load credentials from the configuration file or environment variables:
57
+
58
+ ```typescript
59
+ import { createClient } from '@scaleway/sdk-client'
60
+ import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
61
+ import { EnvironmentalFootprint } from '@scaleway/sdk-environmental-footprint'
62
+
63
+ const profile = loadProfileFromConfigurationFile()
64
+ const client = createClient(profile)
65
+ const api = new EnvironmentalFootprint.v1.API(client)
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ - 📚 [Scaleway SDK Reference Documentation](https://scaleway.github.io/scaleway-sdk-js)
71
+ - 🌐 [Scaleway Environmental Footprint API Documentation](https://www.scaleway.com/en/developers/api/environmental-footprint/)
72
+ - 📖 [Main Repository](https://github.com/scaleway/scaleway-sdk-js)
73
+ - 💡 [Example Projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
74
+
75
+ ## Features
76
+
77
+ - ✅ Full TypeScript support with complete type definitions
78
+ - ✅ Promise-based API
79
+ - ✅ Automatic pagination helpers
80
+ - ✅ Built-in error handling
81
+ - ✅ Compatible with Node.js ≥ 20
82
+
83
+ ## Support
84
+
85
+ We love feedback! Feel free to reach us on:
86
+ - [Scaleway Slack community](https://slack.scaleway.com/) - Join us on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource)
87
+ - [GitHub Issues](https://github.com/scaleway/scaleway-sdk-js/issues)
88
+
89
+ ## Contributing
90
+
91
+ This repository is at its early stage and is still in active development. If you are looking for a way to contribute, please read [CONTRIBUTING.md](https://github.com/scaleway/scaleway-sdk-js/blob/master/CONTRIBUTING.md).
92
+
93
+ ## License
94
+
95
+ This project is Apache 2.0 licensed. See the [LICENSE](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE) file for details.
96
+
@@ -16,10 +16,7 @@ class UserAPI extends API {
16
16
  path: `/environmental-footprint/v1alpha1/reports/availability`,
17
17
  urlParams: urlParams(
18
18
  ["end_date", request.endDate],
19
- [
20
- "organization_id",
21
- request.organizationId ?? this.client.settings.defaultOrganizationId
22
- ],
19
+ ["organization_id", request.organizationId ?? this.client.settings.defaultOrganizationId],
23
20
  ["start_date", request.startDate]
24
21
  )
25
22
  },
@@ -31,27 +28,23 @@ class UserAPI extends API {
31
28
  * @param request - The request {@link UserApiDownloadImpactReportRequest}
32
29
  * @returns A Promise of Blob
33
30
  */
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
- });
31
+ downloadImpactReport = (request = {}) => this.client.fetch(
32
+ {
33
+ body: JSON.stringify(
34
+ marshalUserApiDownloadImpactReportRequest(request, this.client.settings)
35
+ ),
36
+ headers: jsonContentHeaders,
37
+ method: "POST",
38
+ path: `/environmental-footprint/v1alpha1/reports/download`,
39
+ urlParams: urlParams(
40
+ ["dl", 1],
41
+ ["date", request.date],
42
+ ["organization_id", request.organizationId ?? this.client.settings.defaultOrganizationId],
43
+ ["type", request.type]
44
+ ),
45
+ responseType: "blob"
46
+ }
47
+ );
55
48
  /**
56
49
  * 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
50
  *
@@ -64,10 +57,7 @@ class UserAPI extends API {
64
57
  path: `/environmental-footprint/v1alpha1/data/query`,
65
58
  urlParams: urlParams(
66
59
  ["end_date", request.endDate],
67
- [
68
- "organization_id",
69
- request.organizationId ?? this.client.settings.defaultOrganizationId
70
- ],
60
+ ["organization_id", request.organizationId ?? this.client.settings.defaultOrganizationId],
71
61
  ["product_categories", request.productCategories],
72
62
  ["project_ids", request.projectIds],
73
63
  ["regions", request.regions],
@@ -1,3 +1,3 @@
1
- export { UserAPI } from './api.gen.js';
1
+ export { UserAPI, } from './api.gen.js';
2
2
  export * from './marshalling.gen.js';
3
3
  export type { Impact, ImpactDataResponse, ImpactReportAvailability, ProductCategory, ProjectImpact, RegionImpact, ReportType, ServiceCategory, SkuImpact, UserApiDownloadImpactReportRequest, UserApiGetImpactDataRequest, UserApiGetImpactReportAvailabilityRequest, ZoneImpact, } from './types.gen.js';
@@ -79,10 +79,7 @@ const unmarshalImpactReportAvailability = (data) => {
79
79
  );
80
80
  }
81
81
  return {
82
- monthSummaryReports: unmarshalArrayOfObject(
83
- data.month_summary_reports,
84
- unmarshalDate
85
- )
82
+ monthSummaryReports: unmarshalArrayOfObject(data.month_summary_reports, unmarshalDate)
86
83
  };
87
84
  };
88
85
  const marshalUserApiDownloadImpactReportRequest = (request, defaults) => ({
@@ -1,7 +1,7 @@
1
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';
2
+ export type ProductCategory = 'unknown_product_category' | 'apple_silicon' | 'block_storage' | 'dedibox' | 'elastic_metal' | 'instances' | 'object_storage' | 'load_balancer';
3
3
  export type ReportType = 'unknown_report_type' | 'monthly' | 'yearly';
4
- export type ServiceCategory = 'unknown_service_category' | 'baremetal' | 'compute' | 'storage';
4
+ export type ServiceCategory = 'unknown_service_category' | 'baremetal' | 'compute' | 'storage' | 'network';
5
5
  export interface Impact {
6
6
  /**
7
7
  * The estimated carbon emissions in kilograms of CO₂ equivalent (kgCO₂e).
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-environmental-footprint",
3
- "version": "1.2.0",
3
+ "version": "2.2.0",
4
4
  "description": "Scaleway SDK environmental-footprint",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
+ "README.md",
7
8
  "dist"
8
9
  ],
9
10
  "type": "module",
10
11
  "exports": {
11
12
  ".": {
12
13
  "types": "./dist/index.gen.d.ts",
13
- "import": "./dist/index.gen.js",
14
- "require": "./dist/index.gen.cjs",
15
14
  "default": "./dist/index.gen.js"
16
15
  },
17
16
  "./*": {
18
17
  "types": "./dist/*/index.gen.d.ts",
19
- "import": "./dist/*/index.gen.js",
20
- "require": "./dist/*/index.gen.cjs",
21
18
  "default": "./dist/*/index.gen.js"
22
19
  }
23
20
  },
@@ -26,17 +23,17 @@
26
23
  "directory": "packages_generated/environmental-footprint"
27
24
  },
28
25
  "engines": {
29
- "node": ">=20.18.3"
26
+ "node": ">=20.19.6"
30
27
  },
31
28
  "dependencies": {
32
- "@scaleway/random-name": "5.1.1",
33
- "@scaleway/sdk-std": "1.2.0"
29
+ "@scaleway/random-name": "5.1.2",
30
+ "@scaleway/sdk-std": "2.1.0"
34
31
  },
35
32
  "peerDependencies": {
36
- "@scaleway/sdk-client": "^1.3.3"
33
+ "@scaleway/sdk-client": "^2.1.0"
37
34
  },
38
35
  "devDependencies": {
39
- "@scaleway/sdk-client": "^1.3.3"
36
+ "@scaleway/sdk-client": "^2.1.0"
40
37
  },
41
38
  "scripts": {
42
39
  "package:check": "pnpm publint",
@@ -1,4 +0,0 @@
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;
@@ -1,84 +0,0 @@
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;
@@ -1,8 +0,0 @@
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;
@@ -1,97 +0,0 @@
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;