diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-09-26 20:34:49 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-26 20:34:49 +0900 |
commit | 55ac72e56e0cdf6faf2fcd93939d0dd77048a8ee (patch) | |
tree | 8f153205110ce97032b698b420137153ef7fdca8 /lib/google_api | |
parent | 3823707a0bc30ffd61e9bdaf5e05ef2a4dc975e1 (diff) | |
download | gitlab-ce-55ac72e56e0cdf6faf2fcd93939d0dd77048a8ee.tar.gz |
Create cluster
Diffstat (limited to 'lib/google_api')
-rw-r--r-- | lib/google_api/cloud_platform/client.rb | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index baaf2e0d0fb..301b4824bb0 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -1,8 +1,8 @@ +require 'google/apis/container_v1' + module GoogleApi module CloudPlatform class Client < GoogleApi::Authentication - # Google::Apis::ContainerV1::ContainerService.new - class << self def token_in_session :cloud_platform_access_token @@ -13,26 +13,37 @@ module GoogleApi 'https://www.googleapis.com/auth/cloud-platform' end - def projects_zones_clusters_get - # TODO: - # service = Google::Apis::ContainerV1::ContainerService.new - # service.authorization = access_token - # project_id = params['project_id'] - # ... - # response = service.list_zone_clusters(project_id, zone) - response + def projects_zones_clusters_get(project_id:, zone:, cluster_id:) + service = Google::Apis::ContainerV1::ContainerService.new + service.authorization = access_token + + response = service.get_zone_cluster(project_id, zone, cluster_id) + response.to_json end - def projects_zones_clusters_create(gcp_project_id, cluster_zone, cluster_name, cluster_size) - # TODO: Google::Apis::ContainerV1::ContainerService.new + # Responce exmaple + # {"name":"operation-1506424047439-0293f57c","operationType":"CREATE_CLUSTER","selfLink":"https://container.googleapis.com/v1/projects/696404988091/zones/us-central1-a/operations/operation-1506424047439-0293f57c","startTime":"2017-09-26T11:07:27.439033158Z","status":"RUNNING","targetLink":"https://container.googleapis.com/v1/projects/696404988091/zones/us-central1-a/clusters/gke-test-creation","zone":"us-central1-a"} + def projects_zones_clusters_create(project_id:, zone:, cluster_name:, cluster_size:, machine_type:) + service = Google::Apis::ContainerV1::ContainerService.new + service.authorization = access_token + + request_body = Google::Apis::ContainerV1::CreateClusterRequest.new( + { + "cluster": { + "name": cluster_name, + "initial_node_count": cluster_size + } + } + ) + + # TODO: machine_type : Defailt 3.75 GB + response = service.create_cluster(project_id, zone, request_body) + puts response.to_json + response.to_json + end - # TODO: Debug - { - 'end_point' => 'https://111.111.111.111', - 'ca_cert' => 'XXXXXXXXXXXXXXXXXX', - 'username' => 'AAA', - 'password' => 'BBB' - } + def get_status(project_id:, zone:, cluster_name:, cluster_size:, machine_type:) + # Observe end end end |