From 957bedb1c345644f633fdfd3440491810c5cb75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 15 Dec 2017 23:54:50 +0100 Subject: [PATCH] Add Google Cloud client project billing info --- lib/google_api/cloud_platform/client.rb | 8 ++++++++ spec/lib/google_api/cloud_platform/client_spec.rb | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index f0dabcb1c5d..c107d001bec 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -1,4 +1,5 @@ require 'google/apis/container_v1' +require 'google/apis/cloudbilling_v1' require 'google/apis/cloudresourcemanager_v1' module GoogleApi @@ -50,6 +51,13 @@ module GoogleApi end end + def projects_get_billing_info(project_name) + service = Google::Apis::CloudbillingV1::CloudbillingService.new + service.authorization = access_token + + service.get_project_billing_info(project_name) + end + def projects_zones_clusters_get(project_id, zone, cluster_id) service = Google::Apis::ContainerV1::ContainerService.new service.authorization = access_token diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb index 0383b1080dc..2d14c3b1a3a 100644 --- a/spec/lib/google_api/cloud_platform/client_spec.rb +++ b/spec/lib/google_api/cloud_platform/client_spec.rb @@ -62,6 +62,18 @@ describe GoogleApi::CloudPlatform::Client do it { is_expected.to eq(projects) } end + def projects_get_billing_info + subject { client.projects_get_billing_info } + let(:billing_info) { double } + + before do + allow_any_instance_of(Google::Apis::CloudbillingV1::CloudbillingService) + .to receive(:get_project_billing_info).and_return(billing_info) + end + + it { is_expected.to eq(billing_info) } + end + describe '#projects_zones_clusters_get' do subject { client.projects_zones_clusters_get(spy, spy, spy) } let(:gke_cluster) { double }