google-cloud-datastore-admin-v1 0.1.2 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -119,7 +119,7 @@ module Google
119
119
  parent_config = while namespace.any?
120
120
  parent_name = namespace.join "::"
121
121
  parent_const = const_get parent_name
122
- break parent_const.configure if parent_const&.respond_to? :configure
122
+ break parent_const.configure if parent_const.respond_to? :configure
123
123
  namespace.pop
124
124
  end
125
125
  default_config = Client::Configuration.new parent_config
@@ -128,20 +128,18 @@ module Google
128
128
 
129
129
  default_config.rpcs.import_entities.timeout = 60.0
130
130
 
131
+ default_config.rpcs.create_index.timeout = 60.0
132
+
133
+ default_config.rpcs.delete_index.timeout = 60.0
134
+
131
135
  default_config.rpcs.get_index.timeout = 60.0
132
136
  default_config.rpcs.get_index.retry_policy = {
133
- initial_delay: 0.1,
134
- max_delay: 60.0,
135
- multiplier: 1.3,
136
- retry_codes: [14, 4]
137
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
137
138
  }
138
139
 
139
140
  default_config.rpcs.list_indexes.timeout = 60.0
140
141
  default_config.rpcs.list_indexes.retry_policy = {
141
- initial_delay: 0.1,
142
- max_delay: 60.0,
143
- multiplier: 1.3,
144
- retry_codes: [14, 4]
142
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
145
143
  }
146
144
 
147
145
  default_config
@@ -205,8 +203,14 @@ module Google
205
203
 
206
204
  # Create credentials
207
205
  credentials = @config.credentials
208
- credentials ||= Credentials.default scope: @config.scope
209
- if credentials.is_a?(String) || credentials.is_a?(Hash)
206
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
207
+ # but only if the default endpoint does not have a region prefix.
208
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
209
+ @config.endpoint == Client.configure.endpoint &&
210
+ !@config.endpoint.split(".").first.include?("-")
211
+ credentials ||= Credentials.default scope: @config.scope,
212
+ enable_self_signed_jwt: enable_self_signed_jwt
213
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
210
214
  credentials = Credentials.new credentials, scope: @config.scope
211
215
  end
212
216
  @quota_project_id = @config.quota_project
@@ -424,6 +428,168 @@ module Google
424
428
  raise ::Google::Cloud::Error.from_error(e)
425
429
  end
426
430
 
431
+ ##
432
+ # Creates the specified index.
433
+ # A newly created index's initial state is `CREATING`. On completion of the
434
+ # returned {::Google::Longrunning::Operation google.longrunning.Operation}, the state will be `READY`.
435
+ # If the index already exists, the call will return an `ALREADY_EXISTS`
436
+ # status.
437
+ #
438
+ # During index creation, the process could result in an error, in which
439
+ # case the index will move to the `ERROR` state. The process can be recovered
440
+ # by fixing the data that caused the error, removing the index with
441
+ # {::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client#delete_index delete}, then
442
+ # re-creating the index with [create]
443
+ # [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
444
+ #
445
+ # Indexes with a single property cannot be created.
446
+ #
447
+ # @overload create_index(request, options = nil)
448
+ # Pass arguments to `create_index` via a request object, either of type
449
+ # {::Google::Cloud::Datastore::Admin::V1::CreateIndexRequest} or an equivalent Hash.
450
+ #
451
+ # @param request [::Google::Cloud::Datastore::Admin::V1::CreateIndexRequest, ::Hash]
452
+ # A request object representing the call parameters. Required. To specify no
453
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
454
+ # @param options [::Gapic::CallOptions, ::Hash]
455
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
456
+ #
457
+ # @overload create_index(project_id: nil, index: nil)
458
+ # Pass arguments to `create_index` via keyword arguments. Note that at
459
+ # least one keyword argument is required. To specify no parameters, or to keep all
460
+ # the default parameter values, pass an empty Hash as a request object (see above).
461
+ #
462
+ # @param project_id [::String]
463
+ # Project ID against which to make the request.
464
+ # @param index [::Google::Cloud::Datastore::Admin::V1::Index, ::Hash]
465
+ # The index to create. The name and state fields are output only and will be
466
+ # ignored. Single property indexes cannot be created or deleted.
467
+ #
468
+ # @yield [response, operation] Access the result along with the RPC operation
469
+ # @yieldparam response [::Gapic::Operation]
470
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
471
+ #
472
+ # @return [::Gapic::Operation]
473
+ #
474
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
475
+ #
476
+ def create_index request, options = nil
477
+ raise ::ArgumentError, "request must be provided" if request.nil?
478
+
479
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::CreateIndexRequest
480
+
481
+ # Converts hash and nil to an options object
482
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
483
+
484
+ # Customize the options with defaults
485
+ metadata = @config.rpcs.create_index.metadata.to_h
486
+
487
+ # Set x-goog-api-client and x-goog-user-project headers
488
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
489
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
490
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
491
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
492
+
493
+ header_params = {
494
+ "project_id" => request.project_id
495
+ }
496
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
497
+ metadata[:"x-goog-request-params"] ||= request_params_header
498
+
499
+ options.apply_defaults timeout: @config.rpcs.create_index.timeout,
500
+ metadata: metadata,
501
+ retry_policy: @config.rpcs.create_index.retry_policy
502
+ options.apply_defaults metadata: @config.metadata,
503
+ retry_policy: @config.retry_policy
504
+
505
+ @datastore_admin_stub.call_rpc :create_index, request, options: options do |response, operation|
506
+ response = ::Gapic::Operation.new response, @operations_client, options: options
507
+ yield response, operation if block_given?
508
+ return response
509
+ end
510
+ rescue ::GRPC::BadStatus => e
511
+ raise ::Google::Cloud::Error.from_error(e)
512
+ end
513
+
514
+ ##
515
+ # Deletes an existing index.
516
+ # An index can only be deleted if it is in a `READY` or `ERROR` state. On
517
+ # successful execution of the request, the index will be in a `DELETING`
518
+ # {::Google::Cloud::Datastore::Admin::V1::Index::State state}. And on completion of the
519
+ # returned {::Google::Longrunning::Operation google.longrunning.Operation}, the index will be removed.
520
+ #
521
+ # During index deletion, the process could result in an error, in which
522
+ # case the index will move to the `ERROR` state. The process can be recovered
523
+ # by fixing the data that caused the error, followed by calling
524
+ # {::Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client#delete_index delete} again.
525
+ #
526
+ # @overload delete_index(request, options = nil)
527
+ # Pass arguments to `delete_index` via a request object, either of type
528
+ # {::Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest} or an equivalent Hash.
529
+ #
530
+ # @param request [::Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest, ::Hash]
531
+ # A request object representing the call parameters. Required. To specify no
532
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
533
+ # @param options [::Gapic::CallOptions, ::Hash]
534
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
535
+ #
536
+ # @overload delete_index(project_id: nil, index_id: nil)
537
+ # Pass arguments to `delete_index` via keyword arguments. Note that at
538
+ # least one keyword argument is required. To specify no parameters, or to keep all
539
+ # the default parameter values, pass an empty Hash as a request object (see above).
540
+ #
541
+ # @param project_id [::String]
542
+ # Project ID against which to make the request.
543
+ # @param index_id [::String]
544
+ # The resource ID of the index to delete.
545
+ #
546
+ # @yield [response, operation] Access the result along with the RPC operation
547
+ # @yieldparam response [::Gapic::Operation]
548
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
549
+ #
550
+ # @return [::Gapic::Operation]
551
+ #
552
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
553
+ #
554
+ def delete_index request, options = nil
555
+ raise ::ArgumentError, "request must be provided" if request.nil?
556
+
557
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::Admin::V1::DeleteIndexRequest
558
+
559
+ # Converts hash and nil to an options object
560
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
561
+
562
+ # Customize the options with defaults
563
+ metadata = @config.rpcs.delete_index.metadata.to_h
564
+
565
+ # Set x-goog-api-client and x-goog-user-project headers
566
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
567
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
568
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
569
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
570
+
571
+ header_params = {
572
+ "project_id" => request.project_id,
573
+ "index_id" => request.index_id
574
+ }
575
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
576
+ metadata[:"x-goog-request-params"] ||= request_params_header
577
+
578
+ options.apply_defaults timeout: @config.rpcs.delete_index.timeout,
579
+ metadata: metadata,
580
+ retry_policy: @config.rpcs.delete_index.retry_policy
581
+ options.apply_defaults metadata: @config.metadata,
582
+ retry_policy: @config.retry_policy
583
+
584
+ @datastore_admin_stub.call_rpc :delete_index, request, options: options do |response, operation|
585
+ response = ::Gapic::Operation.new response, @operations_client, options: options
586
+ yield response, operation if block_given?
587
+ return response
588
+ end
589
+ rescue ::GRPC::BadStatus => e
590
+ raise ::Google::Cloud::Error.from_error(e)
591
+ end
592
+
427
593
  ##
428
594
  # Gets an index.
429
595
  #
@@ -474,7 +640,7 @@ module Google
474
640
 
475
641
  header_params = {
476
642
  "project_id" => request.project_id,
477
- "index_id" => request.index_id
643
+ "index_id" => request.index_id
478
644
  }
479
645
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
480
646
  metadata[:"x-goog-request-params"] ||= request_params_header
@@ -660,7 +826,7 @@ module Google
660
826
  config_attr :scope, nil, ::String, ::Array, nil
661
827
  config_attr :lib_name, nil, ::String, nil
662
828
  config_attr :lib_version, nil, ::String, nil
663
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
829
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
664
830
  config_attr :interceptors, nil, ::Array, nil
665
831
  config_attr :timeout, nil, ::Numeric, nil
666
832
  config_attr :metadata, nil, ::Hash, nil
@@ -681,7 +847,7 @@ module Google
681
847
  def rpcs
682
848
  @rpcs ||= begin
683
849
  parent_rpcs = nil
684
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
850
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
685
851
  Rpcs.new parent_rpcs
686
852
  end
687
853
  end
@@ -715,6 +881,16 @@ module Google
715
881
  #
716
882
  attr_reader :import_entities
717
883
  ##
884
+ # RPC-specific configuration for `create_index`
885
+ # @return [::Gapic::Config::Method]
886
+ #
887
+ attr_reader :create_index
888
+ ##
889
+ # RPC-specific configuration for `delete_index`
890
+ # @return [::Gapic::Config::Method]
891
+ #
892
+ attr_reader :delete_index
893
+ ##
718
894
  # RPC-specific configuration for `get_index`
719
895
  # @return [::Gapic::Config::Method]
720
896
  #
@@ -727,13 +903,17 @@ module Google
727
903
 
728
904
  # @private
729
905
  def initialize parent_rpcs = nil
730
- export_entities_config = parent_rpcs&.export_entities if parent_rpcs&.respond_to? :export_entities
906
+ export_entities_config = parent_rpcs.export_entities if parent_rpcs.respond_to? :export_entities
731
907
  @export_entities = ::Gapic::Config::Method.new export_entities_config
732
- import_entities_config = parent_rpcs&.import_entities if parent_rpcs&.respond_to? :import_entities
908
+ import_entities_config = parent_rpcs.import_entities if parent_rpcs.respond_to? :import_entities
733
909
  @import_entities = ::Gapic::Config::Method.new import_entities_config
734
- get_index_config = parent_rpcs&.get_index if parent_rpcs&.respond_to? :get_index
910
+ create_index_config = parent_rpcs.create_index if parent_rpcs.respond_to? :create_index
911
+ @create_index = ::Gapic::Config::Method.new create_index_config
912
+ delete_index_config = parent_rpcs.delete_index if parent_rpcs.respond_to? :delete_index
913
+ @delete_index = ::Gapic::Config::Method.new delete_index_config
914
+ get_index_config = parent_rpcs.get_index if parent_rpcs.respond_to? :get_index
735
915
  @get_index = ::Gapic::Config::Method.new get_index_config
736
- list_indexes_config = parent_rpcs&.list_indexes if parent_rpcs&.respond_to? :list_indexes
916
+ list_indexes_config = parent_rpcs.list_indexes if parent_rpcs.respond_to? :list_indexes
737
917
  @list_indexes = ::Gapic::Config::Method.new list_indexes_config
738
918
 
739
919
  yield self if block_given?
@@ -83,7 +83,7 @@ module Google
83
83
  # Create credentials
84
84
  credentials = @config.credentials
85
85
  credentials ||= Credentials.default scope: @config.scope
86
- if credentials.is_a?(String) || credentials.is_a?(Hash)
86
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
87
87
  credentials = Credentials.new credentials, scope: @config.scope
88
88
  end
89
89
  @quota_project_id = @config.quota_project
@@ -104,8 +104,13 @@ module Google
104
104
  # Lists operations that match the specified filter in the request. If the
105
105
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
106
106
  #
107
- # NOTE: the `name` binding below allows API services to override the binding
108
- # to use different resource name schemes, such as `users/*/operations`.
107
+ # NOTE: the `name` binding allows API services to override the binding
108
+ # to use different resource name schemes, such as `users/*/operations`. To
109
+ # override the binding, API services can add a binding such as
110
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
111
+ # For backwards compatibility, the default name includes the operations
112
+ # collection id, however overriding users must ensure the name binding
113
+ # is the parent resource, without the operations collection id.
109
114
  #
110
115
  # @overload list_operations(request, options = nil)
111
116
  # Pass arguments to `list_operations` via a request object, either of type
@@ -123,7 +128,7 @@ module Google
123
128
  # the default parameter values, pass an empty Hash as a request object (see above).
124
129
  #
125
130
  # @param name [::String]
126
- # The name of the operation collection.
131
+ # The name of the operation's parent resource.
127
132
  # @param filter [::String]
128
133
  # The standard list filter.
129
134
  # @param page_size [::Integer]
@@ -391,6 +396,79 @@ module Google
391
396
  raise ::Google::Cloud::Error.from_error(e)
392
397
  end
393
398
 
399
+ ##
400
+ # Waits until the specified long-running operation is done or reaches at most
401
+ # a specified timeout, returning the latest state. If the operation is
402
+ # already done, the latest state is immediately returned. If the timeout
403
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
404
+ # timeout is used. If the server does not support this method, it returns
405
+ # `google.rpc.Code.UNIMPLEMENTED`.
406
+ # Note that this method is on a best-effort basis. It may return the latest
407
+ # state before the specified timeout (including immediately), meaning even an
408
+ # immediate response is no guarantee that the operation is done.
409
+ #
410
+ # @overload wait_operation(request, options = nil)
411
+ # Pass arguments to `wait_operation` via a request object, either of type
412
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
413
+ #
414
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
415
+ # A request object representing the call parameters. Required. To specify no
416
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
417
+ # @param options [::Gapic::CallOptions, ::Hash]
418
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
419
+ #
420
+ # @overload wait_operation(name: nil, timeout: nil)
421
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
422
+ # least one keyword argument is required. To specify no parameters, or to keep all
423
+ # the default parameter values, pass an empty Hash as a request object (see above).
424
+ #
425
+ # @param name [::String]
426
+ # The name of the operation resource to wait on.
427
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
428
+ # The maximum duration to wait before timing out. If left blank, the wait
429
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
430
+ # If RPC context deadline is also specified, the shorter one will be used.
431
+ #
432
+ # @yield [response, operation] Access the result along with the RPC operation
433
+ # @yieldparam response [::Gapic::Operation]
434
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
435
+ #
436
+ # @return [::Gapic::Operation]
437
+ #
438
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
439
+ #
440
+ def wait_operation request, options = nil
441
+ raise ::ArgumentError, "request must be provided" if request.nil?
442
+
443
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
444
+
445
+ # Converts hash and nil to an options object
446
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
447
+
448
+ # Customize the options with defaults
449
+ metadata = @config.rpcs.wait_operation.metadata.to_h
450
+
451
+ # Set x-goog-api-client and x-goog-user-project headers
452
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
453
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
454
+ gapic_version: ::Google::Cloud::Datastore::Admin::V1::VERSION
455
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
456
+
457
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
458
+ metadata: metadata,
459
+ retry_policy: @config.rpcs.wait_operation.retry_policy
460
+ options.apply_defaults metadata: @config.metadata,
461
+ retry_policy: @config.retry_policy
462
+
463
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
464
+ response = ::Gapic::Operation.new response, @operations_client, options: options
465
+ yield response, operation if block_given?
466
+ return response
467
+ end
468
+ rescue ::GRPC::BadStatus => e
469
+ raise ::Google::Cloud::Error.from_error(e)
470
+ end
471
+
394
472
  ##
395
473
  # Configuration class for the Operations API.
396
474
  #
@@ -483,7 +561,7 @@ module Google
483
561
  config_attr :scope, nil, ::String, ::Array, nil
484
562
  config_attr :lib_name, nil, ::String, nil
485
563
  config_attr :lib_version, nil, ::String, nil
486
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
564
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
487
565
  config_attr :interceptors, nil, ::Array, nil
488
566
  config_attr :timeout, nil, ::Numeric, nil
489
567
  config_attr :metadata, nil, ::Hash, nil
@@ -504,7 +582,7 @@ module Google
504
582
  def rpcs
505
583
  @rpcs ||= begin
506
584
  parent_rpcs = nil
507
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
585
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
508
586
  Rpcs.new parent_rpcs
509
587
  end
510
588
  end
@@ -547,17 +625,24 @@ module Google
547
625
  # @return [::Gapic::Config::Method]
548
626
  #
549
627
  attr_reader :cancel_operation
628
+ ##
629
+ # RPC-specific configuration for `wait_operation`
630
+ # @return [::Gapic::Config::Method]
631
+ #
632
+ attr_reader :wait_operation
550
633
 
551
634
  # @private
552
635
  def initialize parent_rpcs = nil
553
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
636
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
554
637
  @list_operations = ::Gapic::Config::Method.new list_operations_config
555
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
638
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
556
639
  @get_operation = ::Gapic::Config::Method.new get_operation_config
557
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
640
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
558
641
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
559
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
642
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
560
643
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
644
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
645
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
561
646
 
562
647
  yield self if block_given?
563
648
  end
@@ -22,7 +22,7 @@ module Google
22
22
  module Datastore
23
23
  module Admin
24
24
  module V1
25
- VERSION = "0.1.2"
25
+ VERSION = "0.4.2"
26
26
  end
27
27
  end
28
28
  end