BigW Consortium Gitlab

Add zones_list and machine_types_list to Google Cloud API client

parent 78fb81e6
require 'google/apis/compute_v1'
require 'google/apis/container_v1'
require 'google/apis/cloudbilling_v1'
require 'google/apis/cloudresourcemanager_v1'
......@@ -58,6 +59,24 @@ module GoogleApi
service.get_project_billing_info("projects/#{project_id}", options: user_agent_header)
end
def projects_zones_list(project_id)
service = Google::Apis::ComputeV1::ComputeService.new
service.authorization = access_token
service.fetch_all do |token|
service.list_zones(project_id, page_token: token, options: user_agent_header)
end
end
def projects_zones_machine_types_list(project_id, zone)
service = Google::Apis::ComputeV1::ComputeService.new
service.authorization = access_token
service.fetch_all do |token|
service.list_machine_types(project_id, zone, page_token: token, options: user_agent_header)
end
end
def projects_zones_clusters_get(project_id, zone, cluster_id)
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
......
......@@ -74,6 +74,30 @@ describe GoogleApi::CloudPlatform::Client do
it { is_expected.to eq(billing_info) }
end
describe '#projects_zones_list' do
subject { client.projects_zones_list('project') }
let(:zones) { double }
before do
allow_any_instance_of(Google::Apis::ComputeV1::ComputeService)
.to receive(:fetch_all).and_return(zones)
end
it { is_expected.to eq(zones) }
end
describe '#projects_zones_machine_types_list' do
subject { client.projects_zones_machine_types_list('project', 'zone') }
let(:machine_types) { double }
before do
allow_any_instance_of(Google::Apis::ComputeV1::ComputeService)
.to receive(:fetch_all).and_return(machine_types)
end
it { is_expected.to eq(machine_types) }
end
describe '#projects_zones_clusters_get' do
subject { client.projects_zones_clusters_get(spy, spy, spy) }
let(:gke_cluster) { double }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment