spanner/spanner_samples.rb
# Copyright 2017 Google, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an " AS IS " BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied . See the License for the specific language governing permissions and limitations under the License .
def create_instance project_id:, instance_id:
  require "google/cloud/spanner"
  spanner  = Google::Cloud::Spanner.new project: project_id
  instance = spanner.instance instance_id
  job = spanner.create_instance instance_id,
                                name:   instance_id,
                                config: "regional-us-central1",
                                nodes:  2,
                                labels: { cloud_spanner_samples: true }
  puts "Waiting for create instance operation to complete"
  job.wait_until_done!
  if job.error?
    puts job.error
  else
    puts "Created instance #{instance_id}"
  end
end
def create_instance project_id : , instance_id : require "google/cloud/spanner" spanner = Google :: Cloud :: Spanner . new project : project_id instance = spanner . instance instance_id job = spanner . create_instance instance_id , name : instance_id , config : "regional-us-central1" , nodes : 2 , labels : { cloud_spanner_samples : true } puts "Waiting for create instance operation to complete" job . wait_until_done! if job . error? puts job . error else puts "Created instance #{instance_id}" end end
Copyright 2017 Google, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Copyright 2017 Google Inc Licensed under the Apache License Version 2 . 0 ( the " License " ) ; you may not use this file except in compliance with the License .
# [START spanner_create_instance] # project_id  = "Your Google Cloud project ID" # instance_id = "Your Spanner instance ID" # [END spanner_create_instance]
project_id
<not_specific>
instance_id
<not_specific>