Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
596ea9e3
Commit
596ea9e3
authored
Dec 15, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Google Cloud client project list
parent
497a0cd6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
lib/google_api/cloud_platform/client.rb
lib/google_api/cloud_platform/client.rb
+10
-0
spec/lib/google_api/cloud_platform/client_spec.rb
spec/lib/google_api/cloud_platform/client_spec.rb
+12
-0
No files found.
lib/google_api/cloud_platform/client.rb
View file @
596ea9e3
require
'google/apis/container_v1'
require
'google/apis/container_v1'
require
'google/apis/cloudresourcemanager_v1'
module
GoogleApi
module
GoogleApi
module
CloudPlatform
module
CloudPlatform
...
@@ -40,6 +41,15 @@ module GoogleApi
...
@@ -40,6 +41,15 @@ module GoogleApi
true
true
end
end
def
projects_list
service
=
Google
::
Apis
::
CloudresourcemanagerV1
::
CloudResourceManagerService
.
new
service
.
authorization
=
access_token
service
.
fetch_all
(
items: :projects
)
do
|
token
|
service
.
list_projects
(
page_token:
token
)
end
end
def
projects_zones_clusters_get
(
project_id
,
zone
,
cluster_id
)
def
projects_zones_clusters_get
(
project_id
,
zone
,
cluster_id
)
service
=
Google
::
Apis
::
ContainerV1
::
ContainerService
.
new
service
=
Google
::
Apis
::
ContainerV1
::
ContainerService
.
new
service
.
authorization
=
access_token
service
.
authorization
=
access_token
...
...
spec/lib/google_api/cloud_platform/client_spec.rb
View file @
596ea9e3
...
@@ -50,6 +50,18 @@ describe GoogleApi::CloudPlatform::Client do
...
@@ -50,6 +50,18 @@ describe GoogleApi::CloudPlatform::Client do
end
end
end
end
describe
'#projects_list'
do
subject
{
client
.
projects_list
}
let
(
:projects
)
{
double
}
before
do
allow_any_instance_of
(
Google
::
Apis
::
CloudresourcemanagerV1
::
CloudResourceManagerService
)
.
to
receive
(
:fetch_all
).
and_return
(
projects
)
end
it
{
is_expected
.
to
eq
(
projects
)
}
end
describe
'#projects_zones_clusters_get'
do
describe
'#projects_zones_clusters_get'
do
subject
{
client
.
projects_zones_clusters_get
(
spy
,
spy
,
spy
)
}
subject
{
client
.
projects_zones_clusters_get
(
spy
,
spy
,
spy
)
}
let
(
:gke_cluster
)
{
double
}
let
(
:gke_cluster
)
{
double
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment