Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@scaleway/sdk-dedibox": "workspace:*",
"@scaleway/sdk-domain": "workspace:*",
"@scaleway/sdk-edge-services": "workspace:*",
"@scaleway/sdk-environmental-footprint": "workspace:*",
"@scaleway/sdk-file": "workspace:*",
"@scaleway/sdk-flexibleip": "workspace:*",
"@scaleway/sdk-function": "workspace:*",
Expand Down
9 changes: 9 additions & 0 deletions packages/sdk/src/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Datawarehousev1beta1 } from '@scaleway/sdk-datawarehouse'
import { Dediboxv1 } from '@scaleway/sdk-dedibox'
import { Domainv2beta1 } from '@scaleway/sdk-domain'
import { EdgeServicesv1beta1 } from '@scaleway/sdk-edge-services'
import { EnvironmentalFootprintv1alpha1 } from '@scaleway/sdk-environmental-footprint'
import { Filev1alpha1 } from '@scaleway/sdk-file'
import { Flexibleipv1alpha1 } from '@scaleway/sdk-flexibleip'
import { Functionv1beta1 } from '@scaleway/sdk-function'
Expand Down Expand Up @@ -153,6 +154,14 @@ export const EdgeServices = {
v1beta1: EdgeServicesv1beta1,
}

/**
* @deprecated Direct version exports are deprecated. Use the 'EnvironmentalFootprint' namespace instead (e.g., EnvironmentalFootprint.v1).
*/
export { EnvironmentalFootprintv1alpha1 }
export const EnvironmentalFootprint = {
v1alpha1: EnvironmentalFootprintv1alpha1,
}

/**
* @deprecated Direct version exports are deprecated. Use the 'File' namespace instead (e.g., File.v1).
*/
Expand Down
48 changes: 48 additions & 0 deletions packages_generated/environmental_footprint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@scaleway/sdk-environmental-footprint",
"version": "1.0.0",
"description": "Scaleway SDK environmental-footprint",
"license": "Apache-2.0",
"files": [
"dist"
],
"type": "module",
"exports": {
".": {
"types": "./dist/index.gen.d.ts",
"import": "./dist/index.gen.js",
"require": "./dist/index.gen.cjs",
"default": "./dist/index.gen.js"
},
"./*": {
"types": "./dist/*/index.gen.d.ts",
"import": "./dist/*/index.gen.js",
"require": "./dist/*/index.gen.cjs",
"default": "./dist/*/index.gen.js"
}
},
"repository": {
"type": "git",
"directory": "packages_generated/environmental-footprint"
},
"engines": {
"node": ">=20.18.3"
},
"scripts": {
"package:check": "pnpm publint",
"typecheck": "tsc --noEmit",
"type:generate": "tsc --declaration -p tsconfig.build.json",
"build": "vite build --config vite.config.ts && pnpm run type:generate",
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts"
},
"dependencies": {
"@scaleway/sdk-std": "workspace:*",
"@scaleway/random-name": "5.1.1"
},
"peerDependencies": {
"@scaleway/sdk-client": "workspace:^"
},
"devDependencies": {
"@scaleway/sdk-client": "workspace:^"
}
}
6 changes: 6 additions & 0 deletions packages_generated/environmental_footprint/src/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated
* PLEASE DO NOT EDIT HERE
*/

export * as EnvironmentalFootprintv1alpha1 from './v1alpha1/index.gen'
112 changes: 112 additions & 0 deletions packages_generated/environmental_footprint/src/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import { API as ParentAPI, urlParams } from '@scaleway/sdk-client'
import {
marshalUserApiDownloadImpactReportRequest,
unmarshalImpactDataResponse,
unmarshalImpactReportAvailability,
} from './marshalling.gen'
import type {
ImpactDataResponse,
ImpactReportAvailability,
UserApiDownloadImpactReportRequest,
UserApiGetImpactDataRequest,
UserApiGetImpactReportAvailabilityRequest,
} from './types.gen'

const jsonContentHeaders = {
'Content-Type': 'application/json; charset=utf-8',
}

/**
* Environmental Footprint API.

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.
*/
export class UserAPI extends ParentAPI {
/**
* Get available impact reports. Returns a list of dates of available impact reports.
*
* @param request - The request {@link UserApiGetImpactReportAvailabilityRequest}
* @returns A Promise of ImpactReportAvailability
*/
getImpactReportAvailability = (
request: Readonly<UserApiGetImpactReportAvailabilityRequest> = {},
) =>
this.client.fetch<ImpactReportAvailability>(
{
method: 'GET',
path: `/environmental-footprint/v1alpha1/reports/availability`,
urlParams: urlParams(
['end_date', request.endDate],
[
'organization_id',
request.organizationId ??
this.client.settings.defaultOrganizationId,
],
['start_date', request.startDate],
),
},
unmarshalImpactReportAvailability,
)

/**
* Download PDF impact report. Download a Scaleway impact PDF report with detailed impact data for your Scaleway projects.
*
* @param request - The request {@link UserApiDownloadImpactReportRequest}
* @returns A Promise of Blob
*/
downloadImpactReport = (
request: Readonly<UserApiDownloadImpactReportRequest> = {},
) =>
this.client.fetch<Blob>({
body: JSON.stringify(
marshalUserApiDownloadImpactReportRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/environmental-footprint/v1alpha1/reports/download`,
urlParams: urlParams(
['dl', 1],
['date', request.date],
[
'organization_id',
request.organizationId ?? this.client.settings.defaultOrganizationId,
],
['type', request.type],
),
responseType: 'blob',
})

/**
* 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.
*
* @param request - The request {@link UserApiGetImpactDataRequest}
* @returns A Promise of ImpactDataResponse
*/
getImpactData = (request: Readonly<UserApiGetImpactDataRequest> = {}) =>
this.client.fetch<ImpactDataResponse>(
{
method: 'GET',
path: `/environmental-footprint/v1alpha1/data/query`,
urlParams: urlParams(
['end_date', request.endDate],
[
'organization_id',
request.organizationId ??
this.client.settings.defaultOrganizationId,
],
['product_categories', request.productCategories],
['project_ids', request.projectIds],
['regions', request.regions],
['service_categories', request.serviceCategories],
['start_date', request.startDate],
['zones', request.zones],
),
},
unmarshalImpactDataResponse,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
export { UserAPI } from './api.gen'
export * from './marshalling.gen'
export type {
Impact,
ImpactDataResponse,
ImpactReportAvailability,
ProductCategory,
ProjectImpact,
RegionImpact,
ReportType,
ServiceCategory,
SkuImpact,
UserApiDownloadImpactReportRequest,
UserApiGetImpactDataRequest,
UserApiGetImpactReportAvailabilityRequest,
ZoneImpact,
} from './types.gen'
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.

import type { DefaultValues } from '@scaleway/sdk-client'
import {
isJSONObject,
unmarshalArrayOfObject,
unmarshalDate,
} from '@scaleway/sdk-client'
import type {
Impact,
ImpactDataResponse,
ImpactReportAvailability,
ProjectImpact,
RegionImpact,
SkuImpact,
UserApiDownloadImpactReportRequest,
ZoneImpact,
} from './types.gen'

const unmarshalImpact = (data: unknown): Impact => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Impact' failed as data isn't a dictionary.`,
)
}

return {
kgCo2Equivalent: data.kg_co2_equivalent,
m3WaterUsage: data.m3_water_usage,
} as Impact
}

const unmarshalSkuImpact = (data: unknown): SkuImpact => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'SkuImpact' failed as data isn't a dictionary.`,
)
}

return {
productCategory: data.product_category,
serviceCategory: data.service_category,
sku: data.sku,
totalSkuImpact: data.total_sku_impact
? unmarshalImpact(data.total_sku_impact)
: undefined,
} as SkuImpact
}

const unmarshalZoneImpact = (data: unknown): ZoneImpact => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ZoneImpact' failed as data isn't a dictionary.`,
)
}

return {
skus: unmarshalArrayOfObject(data.skus, unmarshalSkuImpact),
totalZoneImpact: data.total_zone_impact
? unmarshalImpact(data.total_zone_impact)
: undefined,
zone: data.zone,
} as ZoneImpact
}

const unmarshalRegionImpact = (data: unknown): RegionImpact => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'RegionImpact' failed as data isn't a dictionary.`,
)
}

return {
region: data.region,
totalRegionImpact: data.total_region_impact
? unmarshalImpact(data.total_region_impact)
: undefined,
zones: unmarshalArrayOfObject(data.zones, unmarshalZoneImpact),
} as RegionImpact
}

const unmarshalProjectImpact = (data: unknown): ProjectImpact => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ProjectImpact' failed as data isn't a dictionary.`,
)
}

return {
projectId: data.project_id,
regions: unmarshalArrayOfObject(data.regions, unmarshalRegionImpact),
totalProjectImpact: data.total_project_impact
? unmarshalImpact(data.total_project_impact)
: undefined,
} as ProjectImpact
}

export const unmarshalImpactDataResponse = (
data: unknown,
): ImpactDataResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ImpactDataResponse' failed as data isn't a dictionary.`,
)
}

return {
endDate: unmarshalDate(data.end_date),
projects: unmarshalArrayOfObject(data.projects, unmarshalProjectImpact),
startDate: unmarshalDate(data.start_date),
totalImpact: data.total_impact
? unmarshalImpact(data.total_impact)
: undefined,
} as ImpactDataResponse
}

export const unmarshalImpactReportAvailability = (
data: unknown,
): ImpactReportAvailability => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ImpactReportAvailability' failed as data isn't a dictionary.`,
)
}

return {
monthSummaryReports: unmarshalArrayOfObject(
data.month_summary_reports,
unmarshalDate,
),
} as ImpactReportAvailability
}

export const marshalUserApiDownloadImpactReportRequest = (
request: UserApiDownloadImpactReportRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
date: request.date,
organization_id: request.organizationId ?? defaults.defaultOrganizationId,
type: request.type,
})
Loading
Loading