google-cloud-spanner 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab2f6de02b2dc38f872be9ecf0b9a538353c23457d7d82277bab5e636420b2a4
4
- data.tar.gz: 31e72548e11120e24de11bf932fc5c575478ba5732e21b4610ac42fa3af695ad
3
+ metadata.gz: a644a78d0458b414ee8e19707abfe33b7d34b730af57feb623053929120d9425
4
+ data.tar.gz: db692fd3ac651dea2aaa178e4d6a117bb790cb10fb4571a0f991d940a8d558db
5
5
  SHA512:
6
- metadata.gz: ef87329e6ccc9269a894aafaa179016269ed61a9ebcf338a51faa9a43027fdda825d05b534bda2946a101f9896dc5d98b861e714fc24aa64e5585423c0489548
7
- data.tar.gz: 5d7e360cf9678935eb7d295bca0f808c942a217310d5bfb81dbc0eb3357020f2f32e8d40ef2ffa838c8faf56b882592b5d373e4261bb6ec67ec5acdb867920d4
6
+ metadata.gz: bfbc02dc59071018e559f8062b43dfa3dbd2700ee9da873abce56cdb44ca7a987465e3a567a592f3944a5b16d7995516b34d92be3bf30f810258b5b5c8d6c911
7
+ data.tar.gz: eb58bcc4cf290b9419fa7ecd627898014f39eed6e18150236e7a62a1623fdbd16f4f8cf135cb483c6f278032f83b019a9ea6478814658a9aa8dd58b9a6fc0b78
@@ -65,10 +65,11 @@ module Google
65
65
  class BatchClient
66
66
  ##
67
67
  # @private Creates a new Spanner BatchClient instance.
68
- def initialize project, instance_id, database_id
68
+ def initialize project, instance_id, database_id, session_labels: nil
69
69
  @project = project
70
70
  @instance_id = instance_id
71
71
  @database_id = database_id
72
+ @session_labels = session_labels
72
73
  end
73
74
 
74
75
  # The unique identifier for the project.
@@ -406,7 +407,8 @@ module Google
406
407
  grpc = @project.service.create_session \
407
408
  Admin::Database::V1::DatabaseAdminClient.database_path(
408
409
  project_id, instance_id, database_id
409
- )
410
+ ),
411
+ labels: @session_labels
410
412
  Session.from_grpc(grpc, @project.service)
411
413
  end
412
414
 
@@ -52,11 +52,13 @@ module Google
52
52
  class Client
53
53
  ##
54
54
  # @private Creates a new Spanner Client instance.
55
- def initialize project, instance_id, database_id, opts = {}
55
+ def initialize project, instance_id, database_id, session_labels: nil,
56
+ pool_opts: {}
56
57
  @project = project
57
58
  @instance_id = instance_id
58
59
  @database_id = database_id
59
- @pool = Pool.new self, opts
60
+ @session_labels = session_labels
61
+ @pool = Pool.new self, pool_opts
60
62
  end
61
63
 
62
64
  # The unique identifier for the project.
@@ -1091,7 +1093,8 @@ module Google
1091
1093
  grpc = @project.service.create_session \
1092
1094
  Admin::Database::V1::DatabaseAdminClient.database_path(
1093
1095
  project_id, instance_id, database_id
1094
- )
1096
+ ),
1097
+ labels: @session_labels
1095
1098
  Session.from_grpc(grpc, @project.service)
1096
1099
  end
1097
1100
 
@@ -219,6 +219,8 @@ module Google
219
219
  def create_instance instance_id, name: nil, config: nil, nodes: nil,
220
220
  labels: nil
221
221
  config = config.path if config.respond_to? :path
222
+ # Convert from possible Google::Protobuf::Map
223
+ labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
222
224
  grpc = service.create_instance \
223
225
  instance_id, name: name, config: config, nodes: nodes,
224
226
  labels: labels
@@ -435,6 +437,21 @@ module Google
435
437
  # becomes available. The default is `true`.
436
438
  # * `:threads` (Integer) The number of threads in the thread pool. The
437
439
  # default is twice the number of available CPUs.
440
+ # @param [Hash] labels The labels to be applied to all sessions
441
+ # created by the client. Cloud Labels are a flexible and lightweight
442
+ # mechanism for organizing cloud resources into groups that reflect a
443
+ # customer's organizational needs and deployment strategies. Cloud
444
+ # Labels can be used to filter collections of resources. They can be
445
+ # used to control how resource metrics are aggregated. And they can be
446
+ # used as arguments to policy management rules (e.g. route, firewall,
447
+ # load balancing, etc.). Optional. The default is `nil`.
448
+ #
449
+ # * Label keys must be between 1 and 63 characters long and must
450
+ # conform to the following regular expression:
451
+ # `[a-z]([-a-z0-9]*[a-z0-9])?`.
452
+ # * Label values must be between 0 and 63 characters long and must
453
+ # conform to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
454
+ # * No more than 64 labels can be associated with a given resource.
438
455
  #
439
456
  # @return [Client] The newly created client.
440
457
  #
@@ -453,9 +470,12 @@ module Google
453
470
  # end
454
471
  # end
455
472
  #
456
- def client instance_id, database_id, pool: {}
473
+ def client instance_id, database_id, pool: {}, labels: nil
474
+ # Convert from possible Google::Protobuf::Map
475
+ labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
457
476
  Client.new self, instance_id, database_id,
458
- valid_session_pool_options(pool)
477
+ session_labels: labels,
478
+ pool_opts: valid_session_pool_options(pool)
459
479
  end
460
480
 
461
481
  ##
@@ -466,6 +486,21 @@ module Google
466
486
  # Required.
467
487
  # @param [String] database_id The unique identifier for the database.
468
488
  # Required.
489
+ # @param [Hash] labels The labels to be applied to all sessions
490
+ # created by the batch client. Labels are a flexible and lightweight
491
+ # mechanism for organizing cloud resources into groups that reflect a
492
+ # customer's organizational needs and deployment strategies. Cloud
493
+ # Labels can be used to filter collections of resources. They can be
494
+ # used to control how resource metrics are aggregated. And they can be
495
+ # used as arguments to policy management rules (e.g. route, firewall,
496
+ # load balancing, etc.). Optional. The default is `nil`.
497
+ #
498
+ # * Label keys must be between 1 and 63 characters long and must
499
+ # conform to the following regular expression:
500
+ # `[a-z]([-a-z0-9]*[a-z0-9])?`.
501
+ # * Label values must be between 0 and 63 characters long and must
502
+ # conform to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
503
+ # * No more than 64 labels can be associated with a given resource.
469
504
  #
470
505
  # @return [Client] The newly created client.
471
506
  #
@@ -494,8 +529,10 @@ module Google
494
529
  # results = new_batch_snapshot.execute_partition \
495
530
  # new_partition
496
531
  #
497
- def batch_client instance_id, database_id
498
- BatchClient.new self, instance_id, database_id
532
+ def batch_client instance_id, database_id, labels: nil
533
+ # Convert from possible Google::Protobuf::Map
534
+ labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
535
+ BatchClient.new self, instance_id, database_id, session_labels: labels
499
536
  end
500
537
 
501
538
  protected
@@ -206,6 +206,8 @@ module Google
206
206
  results.instance_variable_set :@enum, enum
207
207
  results.instance_variable_set :@service, service
208
208
  end
209
+ rescue GRPC::BadStatus => e
210
+ raise Google::Cloud::Error.from_error(e)
209
211
  end
210
212
 
211
213
  # @private
@@ -241,10 +241,12 @@ module Google
241
241
  end
242
242
  end
243
243
 
244
- def create_session database_name
244
+ def create_session database_name, labels: nil
245
245
  opts = default_options_from_session database_name
246
+ session = Google::Spanner::V1::Session.new(labels: labels) if labels
246
247
  execute do
247
- service.create_session database_name, options: opts
248
+ service.create_session database_name, session: session,
249
+ options: opts
248
250
  end
249
251
  end
250
252
 
@@ -597,10 +597,12 @@ module Google
597
597
  @last_updated_at = Time.now
598
598
  return self
599
599
  rescue Google::Cloud::NotFoundError
600
+ labels = @grpc.labels.to_h unless @grpc.labels.to_h.empty?
600
601
  @grpc = service.create_session \
601
602
  Admin::Database::V1::DatabaseAdminClient.database_path(
602
603
  project_id, instance_id, database_id
603
- )
604
+ ),
605
+ labels: labels
604
606
  @last_updated_at = Time.now
605
607
  return self
606
608
  end
@@ -613,10 +615,12 @@ module Google
613
615
  execute "SELECT 1"
614
616
  return true
615
617
  rescue Google::Cloud::NotFoundError
618
+ labels = @grpc.labels.to_h unless @grpc.labels.to_h.empty?
616
619
  @grpc = service.create_session \
617
620
  Admin::Database::V1::DatabaseAdminClient.database_path(
618
621
  project_id, instance_id, database_id
619
- )
622
+ ),
623
+ labels: labels
620
624
  return false
621
625
  end
622
626
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Spanner
19
- VERSION = "1.5.0".freeze
19
+ VERSION = "1.6.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-spanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-12 00:00:00.000000000 Z
12
+ date: 2018-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core