UNPKG

@cloud-carbon-footprint/gcp

Version:

The core logic to get cloud usage data and estimate energy and carbon emissions from Google Cloud Platform.

35 lines (34 loc) 2.24 kB
import { ProjectsClient } from '@google-cloud/resource-manager'; import { RecommenderClient } from '@google-cloud/recommender'; import { protos as googleCompute, InstancesClient, DisksClient, AddressesClient, ImagesClient, MachineTypesClient } from '@google-cloud/compute'; import { GoogleAuthClient } from '@cloud-carbon-footprint/common'; import { ActiveProject, RecommenderRecommendations } from './RecommendationsTypes'; import Instance = googleCompute.google.cloud.compute.v1.IInstance; import MachineType = googleCompute.google.cloud.compute.v1.IMachineType; import Disk = googleCompute.google.cloud.compute.v1.IDisk; import Image = googleCompute.google.cloud.compute.v1.IImage; import Address = googleCompute.google.cloud.compute.v1.IAddress; export default class ServiceWrapper { private readonly projectsClient; private readonly authClient; private readonly instancesClient; private readonly disksClient; private readonly addressesClient; private readonly imagesClient; private readonly machineTypesClient; private readonly recommenderClient; private readonly serviceWrapperLogger; private readonly noResultsOnPageMessage; constructor(projectsClient: ProjectsClient, authClient: GoogleAuthClient, instancesClient: InstancesClient, disksClient: DisksClient, addressesClient: AddressesClient, imagesClient: ImagesClient, machineTypesClient: MachineTypesClient, recommenderClient: RecommenderClient); getActiveProjectsAndZones(): Promise<ActiveProject[]>; private getProjects; private getZonesForProject; private extractZones; getRecommendationsForRecommenderIds(projectId: string, zone: string, recommenderIds: string[]): Promise<RecommenderRecommendations[]>; getInstanceDetails(projectId: string, instanceId: string, zone: string): Promise<Instance>; getMachineTypeDetails(projectId: string, machineType: string, zone: string): Promise<MachineType>; getStorageTypeFromDiskName(diskName: string): string; getDiskDetails(projectId: string, diskId: string, zone: string): Promise<Disk>; getImageDetails(projectId: string, imageId: string): Promise<Image>; getAddressDetails(projectId: string, addressId: string, zone: string): Promise<Address>; }