google-cloud-service_usage-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +139 -0
  6. data/lib/google-cloud-service_usage-v1.rb +21 -0
  7. data/lib/google/api/serviceusage/v1/resources_pb.rb +57 -0
  8. data/lib/google/api/serviceusage/v1/serviceusage_pb.rb +86 -0
  9. data/lib/google/api/serviceusage/v1/serviceusage_services_pb.rb +80 -0
  10. data/lib/google/cloud/service_usage/v1.rb +38 -0
  11. data/lib/google/cloud/service_usage/v1/service_usage.rb +53 -0
  12. data/lib/google/cloud/service_usage/v1/service_usage/client.rb +850 -0
  13. data/lib/google/cloud/service_usage/v1/service_usage/credentials.rb +53 -0
  14. data/lib/google/cloud/service_usage/v1/service_usage/operations.rb +655 -0
  15. data/lib/google/cloud/service_usage/v1/version.rb +28 -0
  16. data/proto_docs/README.md +4 -0
  17. data/proto_docs/google/api/auth.rb +247 -0
  18. data/proto_docs/google/api/documentation.rb +170 -0
  19. data/proto_docs/google/api/endpoint.rb +70 -0
  20. data/proto_docs/google/api/label.rb +49 -0
  21. data/proto_docs/google/api/launch_stage.rb +71 -0
  22. data/proto_docs/google/api/monitored_resource.rb +138 -0
  23. data/proto_docs/google/api/monitoring.rb +110 -0
  24. data/proto_docs/google/api/quota.rb +207 -0
  25. data/proto_docs/google/api/resource.rb +283 -0
  26. data/proto_docs/google/api/serviceusage/v1/resources.rb +122 -0
  27. data/proto_docs/google/api/serviceusage/v1/serviceusage.rb +242 -0
  28. data/proto_docs/google/api/usage.rb +100 -0
  29. data/proto_docs/google/longrunning/operations.rb +164 -0
  30. data/proto_docs/google/protobuf/any.rb +141 -0
  31. data/proto_docs/google/protobuf/api.rb +194 -0
  32. data/proto_docs/google/protobuf/duration.rb +98 -0
  33. data/proto_docs/google/protobuf/empty.rb +36 -0
  34. data/proto_docs/google/protobuf/source_context.rb +33 -0
  35. data/proto_docs/google/protobuf/struct.rb +96 -0
  36. data/proto_docs/google/protobuf/type.rb +223 -0
  37. data/proto_docs/google/rpc/status.rb +46 -0
  38. metadata +229 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/service_usage/v1"
@@ -0,0 +1,57 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/api/serviceusage/v1/resources.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/auth_pb'
7
+ require 'google/api/documentation_pb'
8
+ require 'google/api/endpoint_pb'
9
+ require 'google/api/monitored_resource_pb'
10
+ require 'google/api/monitoring_pb'
11
+ require 'google/api/quota_pb'
12
+ require 'google/api/usage_pb'
13
+ require 'google/protobuf/api_pb'
14
+ require 'google/api/annotations_pb'
15
+ Google::Protobuf::DescriptorPool.generated_pool.build do
16
+ add_file("google/api/serviceusage/v1/resources.proto", :syntax => :proto3) do
17
+ add_message "google.api.serviceusage.v1.Service" do
18
+ optional :name, :string, 1
19
+ optional :parent, :string, 5
20
+ optional :config, :message, 2, "google.api.serviceusage.v1.ServiceConfig"
21
+ optional :state, :enum, 4, "google.api.serviceusage.v1.State"
22
+ end
23
+ add_message "google.api.serviceusage.v1.ServiceConfig" do
24
+ optional :name, :string, 1
25
+ optional :title, :string, 2
26
+ repeated :apis, :message, 3, "google.protobuf.Api"
27
+ optional :documentation, :message, 6, "google.api.Documentation"
28
+ optional :quota, :message, 10, "google.api.Quota"
29
+ optional :authentication, :message, 11, "google.api.Authentication"
30
+ optional :usage, :message, 15, "google.api.Usage"
31
+ repeated :endpoints, :message, 18, "google.api.Endpoint"
32
+ repeated :monitored_resources, :message, 25, "google.api.MonitoredResourceDescriptor"
33
+ optional :monitoring, :message, 28, "google.api.Monitoring"
34
+ end
35
+ add_message "google.api.serviceusage.v1.OperationMetadata" do
36
+ repeated :resource_names, :string, 2
37
+ end
38
+ add_enum "google.api.serviceusage.v1.State" do
39
+ value :STATE_UNSPECIFIED, 0
40
+ value :DISABLED, 1
41
+ value :ENABLED, 2
42
+ end
43
+ end
44
+ end
45
+
46
+ module Google
47
+ module Cloud
48
+ module ServiceUsage
49
+ module V1
50
+ Service = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.Service").msgclass
51
+ ServiceConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.ServiceConfig").msgclass
52
+ OperationMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.OperationMetadata").msgclass
53
+ State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.State").enummodule
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,86 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/api/serviceusage/v1/serviceusage.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/serviceusage/v1/resources_pb'
8
+ require 'google/longrunning/operations_pb'
9
+ require 'google/api/client_pb'
10
+ Google::Protobuf::DescriptorPool.generated_pool.build do
11
+ add_file("google/api/serviceusage/v1/serviceusage.proto", :syntax => :proto3) do
12
+ add_message "google.api.serviceusage.v1.EnableServiceRequest" do
13
+ optional :name, :string, 1
14
+ end
15
+ add_message "google.api.serviceusage.v1.EnableServiceResponse" do
16
+ optional :service, :message, 1, "google.api.serviceusage.v1.Service"
17
+ end
18
+ add_message "google.api.serviceusage.v1.DisableServiceRequest" do
19
+ optional :name, :string, 1
20
+ optional :disable_dependent_services, :bool, 2
21
+ optional :check_if_service_has_usage, :enum, 3, "google.api.serviceusage.v1.DisableServiceRequest.CheckIfServiceHasUsage"
22
+ end
23
+ add_enum "google.api.serviceusage.v1.DisableServiceRequest.CheckIfServiceHasUsage" do
24
+ value :CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED, 0
25
+ value :SKIP, 1
26
+ value :CHECK, 2
27
+ end
28
+ add_message "google.api.serviceusage.v1.DisableServiceResponse" do
29
+ optional :service, :message, 1, "google.api.serviceusage.v1.Service"
30
+ end
31
+ add_message "google.api.serviceusage.v1.GetServiceRequest" do
32
+ optional :name, :string, 1
33
+ end
34
+ add_message "google.api.serviceusage.v1.ListServicesRequest" do
35
+ optional :parent, :string, 1
36
+ optional :page_size, :int32, 2
37
+ optional :page_token, :string, 3
38
+ optional :filter, :string, 4
39
+ end
40
+ add_message "google.api.serviceusage.v1.ListServicesResponse" do
41
+ repeated :services, :message, 1, "google.api.serviceusage.v1.Service"
42
+ optional :next_page_token, :string, 2
43
+ end
44
+ add_message "google.api.serviceusage.v1.BatchEnableServicesRequest" do
45
+ optional :parent, :string, 1
46
+ repeated :service_ids, :string, 2
47
+ end
48
+ add_message "google.api.serviceusage.v1.BatchEnableServicesResponse" do
49
+ repeated :services, :message, 1, "google.api.serviceusage.v1.Service"
50
+ repeated :failures, :message, 2, "google.api.serviceusage.v1.BatchEnableServicesResponse.EnableFailure"
51
+ end
52
+ add_message "google.api.serviceusage.v1.BatchEnableServicesResponse.EnableFailure" do
53
+ optional :service_id, :string, 1
54
+ optional :error_message, :string, 2
55
+ end
56
+ add_message "google.api.serviceusage.v1.BatchGetServicesRequest" do
57
+ optional :parent, :string, 1
58
+ repeated :names, :string, 2
59
+ end
60
+ add_message "google.api.serviceusage.v1.BatchGetServicesResponse" do
61
+ repeated :services, :message, 1, "google.api.serviceusage.v1.Service"
62
+ end
63
+ end
64
+ end
65
+
66
+ module Google
67
+ module Cloud
68
+ module ServiceUsage
69
+ module V1
70
+ EnableServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.EnableServiceRequest").msgclass
71
+ EnableServiceResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.EnableServiceResponse").msgclass
72
+ DisableServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.DisableServiceRequest").msgclass
73
+ DisableServiceRequest::CheckIfServiceHasUsage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.DisableServiceRequest.CheckIfServiceHasUsage").enummodule
74
+ DisableServiceResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.DisableServiceResponse").msgclass
75
+ GetServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.GetServiceRequest").msgclass
76
+ ListServicesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.ListServicesRequest").msgclass
77
+ ListServicesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.ListServicesResponse").msgclass
78
+ BatchEnableServicesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.BatchEnableServicesRequest").msgclass
79
+ BatchEnableServicesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.BatchEnableServicesResponse").msgclass
80
+ BatchEnableServicesResponse::EnableFailure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.BatchEnableServicesResponse.EnableFailure").msgclass
81
+ BatchGetServicesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.BatchGetServicesRequest").msgclass
82
+ BatchGetServicesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.api.serviceusage.v1.BatchGetServicesResponse").msgclass
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,80 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/api/serviceusage/v1/serviceusage.proto for package 'Google.Cloud.ServiceUsage.V1'
3
+ # Original file comments:
4
+ # Copyright 2021 Google LLC
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'grpc'
20
+ require 'google/api/serviceusage/v1/serviceusage_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module ServiceUsage
25
+ module V1
26
+ module ServiceUsage
27
+ # Enables services that service consumers want to use on Google Cloud Platform,
28
+ # lists the available or enabled services, or disables services that service
29
+ # consumers no longer use.
30
+ #
31
+ # See [Service Usage API](https://cloud.google.com/service-usage/docs/overview)
32
+ class Service
33
+
34
+ include GRPC::GenericService
35
+
36
+ self.marshal_class_method = :encode
37
+ self.unmarshal_class_method = :decode
38
+ self.service_name = 'google.api.serviceusage.v1.ServiceUsage'
39
+
40
+ # Enable a service so that it can be used with a project.
41
+ rpc :EnableService, ::Google::Cloud::ServiceUsage::V1::EnableServiceRequest, ::Google::Longrunning::Operation
42
+ # Disable a service so that it can no longer be used with a project.
43
+ # This prevents unintended usage that may cause unexpected billing
44
+ # charges or security leaks.
45
+ #
46
+ # It is not valid to call the disable method on a service that is not
47
+ # currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
48
+ # the target service is not currently enabled.
49
+ rpc :DisableService, ::Google::Cloud::ServiceUsage::V1::DisableServiceRequest, ::Google::Longrunning::Operation
50
+ # Returns the service configuration and enabled state for a given service.
51
+ rpc :GetService, ::Google::Cloud::ServiceUsage::V1::GetServiceRequest, ::Google::Cloud::ServiceUsage::V1::Service
52
+ # List all services available to the specified project, and the current
53
+ # state of those services with respect to the project. The list includes
54
+ # all public services, all services for which the calling user has the
55
+ # `servicemanagement.services.bind` permission, and all services that have
56
+ # already been enabled on the project. The list can be filtered to
57
+ # only include services in a specific state, for example to only include
58
+ # services enabled on the project.
59
+ #
60
+ # WARNING: If you need to query enabled services frequently or across
61
+ # an organization, you should use
62
+ # [Cloud Asset Inventory
63
+ # API](https://cloud.google.com/asset-inventory/docs/apis), which provides
64
+ # higher throughput and richer filtering capability.
65
+ rpc :ListServices, ::Google::Cloud::ServiceUsage::V1::ListServicesRequest, ::Google::Cloud::ServiceUsage::V1::ListServicesResponse
66
+ # Enable multiple services on a project. The operation is atomic: if enabling
67
+ # any service fails, then the entire batch fails, and no state changes occur.
68
+ # To enable a single service, use the `EnableService` method instead.
69
+ rpc :BatchEnableServices, ::Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest, ::Google::Longrunning::Operation
70
+ # Returns the service configurations and enabled states for a given list of
71
+ # services.
72
+ rpc :BatchGetServices, ::Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest, ::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse
73
+ end
74
+
75
+ Stub = Service.rpc_stub_class
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/service_usage/v1/service_usage"
20
+ require "google/cloud/service_usage/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module ServiceUsage
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/service_usage/v1"
29
+ # client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new
30
+ #
31
+ module V1
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
38
+ require "google/cloud/service_usage/v1/_helpers" if ::File.file? helper_path
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/service_usage/v1/version"
24
+
25
+ require "google/cloud/service_usage/v1/service_usage/credentials"
26
+ require "google/cloud/service_usage/v1/service_usage/operations"
27
+ require "google/cloud/service_usage/v1/service_usage/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module ServiceUsage
32
+ module V1
33
+ ##
34
+ # Enables services that service consumers want to use on Google Cloud Platform,
35
+ # lists the available or enabled services, or disables services that service
36
+ # consumers no longer use.
37
+ #
38
+ # See [Service Usage API](https://cloud.google.com/service-usage/docs/overview)
39
+ #
40
+ # To load this service and instantiate a client:
41
+ #
42
+ # require "google/cloud/service_usage/v1/service_usage"
43
+ # client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new
44
+ #
45
+ module ServiceUsage
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ helper_path = ::File.join __dir__, "service_usage", "helpers.rb"
53
+ require "google/cloud/service_usage/v1/service_usage/helpers" if ::File.file? helper_path
@@ -0,0 +1,850 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/api/serviceusage/v1/serviceusage_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module ServiceUsage
25
+ module V1
26
+ module ServiceUsage
27
+ ##
28
+ # Client for the ServiceUsage service.
29
+ #
30
+ # Enables services that service consumers want to use on Google Cloud Platform,
31
+ # lists the available or enabled services, or disables services that service
32
+ # consumers no longer use.
33
+ #
34
+ # See [Service Usage API](https://cloud.google.com/service-usage/docs/overview)
35
+ #
36
+ class Client
37
+ # @private
38
+ attr_reader :service_usage_stub
39
+
40
+ ##
41
+ # Configure the ServiceUsage Client class.
42
+ #
43
+ # See {::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # ## Example
47
+ #
48
+ # To modify the configuration for all ServiceUsage clients:
49
+ #
50
+ # ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "ServiceUsage", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.timeout = 60.0
71
+
72
+ default_config
73
+ end
74
+ yield @configure if block_given?
75
+ @configure
76
+ end
77
+
78
+ ##
79
+ # Configure the ServiceUsage Client instance.
80
+ #
81
+ # The configuration is set to the derived mode, meaning that values can be changed,
82
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
83
+ # should be made on {Client.configure}.
84
+ #
85
+ # See {::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client::Configuration}
86
+ # for a description of the configuration fields.
87
+ #
88
+ # @yield [config] Configure the Client client.
89
+ # @yieldparam config [Client::Configuration]
90
+ #
91
+ # @return [Client::Configuration]
92
+ #
93
+ def configure
94
+ yield @config if block_given?
95
+ @config
96
+ end
97
+
98
+ ##
99
+ # Create a new ServiceUsage client object.
100
+ #
101
+ # ## Examples
102
+ #
103
+ # To create a new ServiceUsage client with the default
104
+ # configuration:
105
+ #
106
+ # client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new
107
+ #
108
+ # To create a new ServiceUsage client with a custom
109
+ # configuration:
110
+ #
111
+ # client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the ServiceUsage client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # These require statements are intentionally placed here to initialize
120
+ # the gRPC module only when it's required.
121
+ # See https://github.com/googleapis/toolkit/issues/446
122
+ require "gapic/grpc"
123
+ require "google/api/serviceusage/v1/serviceusage_services_pb"
124
+
125
+ # Create the configuration object
126
+ @config = Configuration.new Client.configure
127
+
128
+ # Yield the configuration if needed
129
+ yield @config if block_given?
130
+
131
+ # Create credentials
132
+ credentials = @config.credentials
133
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
134
+ # but only if the default endpoint does not have a region prefix.
135
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
136
+ @config.endpoint == Client.configure.endpoint &&
137
+ !@config.endpoint.split(".").first.include?("-")
138
+ credentials ||= Credentials.default scope: @config.scope,
139
+ enable_self_signed_jwt: enable_self_signed_jwt
140
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
141
+ credentials = Credentials.new credentials, scope: @config.scope
142
+ end
143
+ @quota_project_id = @config.quota_project
144
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
145
+
146
+ @operations_client = Operations.new do |config|
147
+ config.credentials = credentials
148
+ config.endpoint = @config.endpoint
149
+ end
150
+
151
+ @service_usage_stub = ::Gapic::ServiceStub.new(
152
+ ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Stub,
153
+ credentials: credentials,
154
+ endpoint: @config.endpoint,
155
+ channel_args: @config.channel_args,
156
+ interceptors: @config.interceptors
157
+ )
158
+ end
159
+
160
+ ##
161
+ # Get the associated client for long-running operations.
162
+ #
163
+ # @return [::Google::Cloud::ServiceUsage::V1::ServiceUsage::Operations]
164
+ #
165
+ attr_reader :operations_client
166
+
167
+ # Service calls
168
+
169
+ ##
170
+ # Enable a service so that it can be used with a project.
171
+ #
172
+ # @overload enable_service(request, options = nil)
173
+ # Pass arguments to `enable_service` via a request object, either of type
174
+ # {::Google::Cloud::ServiceUsage::V1::EnableServiceRequest} or an equivalent Hash.
175
+ #
176
+ # @param request [::Google::Cloud::ServiceUsage::V1::EnableServiceRequest, ::Hash]
177
+ # A request object representing the call parameters. Required. To specify no
178
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
179
+ # @param options [::Gapic::CallOptions, ::Hash]
180
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
181
+ #
182
+ # @overload enable_service(name: nil)
183
+ # Pass arguments to `enable_service` via keyword arguments. Note that at
184
+ # least one keyword argument is required. To specify no parameters, or to keep all
185
+ # the default parameter values, pass an empty Hash as a request object (see above).
186
+ #
187
+ # @param name [::String]
188
+ # Name of the consumer and service to enable the service on.
189
+ #
190
+ # The `EnableService` and `DisableService` methods currently only support
191
+ # projects.
192
+ #
193
+ # Enabling a service requires that the service is public or is shared with
194
+ # the user enabling the service.
195
+ #
196
+ # An example name would be:
197
+ # `projects/123/services/serviceusage.googleapis.com` where `123` is the
198
+ # project number.
199
+ #
200
+ # @yield [response, operation] Access the result along with the RPC operation
201
+ # @yieldparam response [::Gapic::Operation]
202
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
203
+ #
204
+ # @return [::Gapic::Operation]
205
+ #
206
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
207
+ #
208
+ def enable_service request, options = nil
209
+ raise ::ArgumentError, "request must be provided" if request.nil?
210
+
211
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::EnableServiceRequest
212
+
213
+ # Converts hash and nil to an options object
214
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
215
+
216
+ # Customize the options with defaults
217
+ metadata = @config.rpcs.enable_service.metadata.to_h
218
+
219
+ # Set x-goog-api-client and x-goog-user-project headers
220
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
221
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
222
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
223
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
224
+
225
+ header_params = {
226
+ "name" => request.name
227
+ }
228
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
229
+ metadata[:"x-goog-request-params"] ||= request_params_header
230
+
231
+ options.apply_defaults timeout: @config.rpcs.enable_service.timeout,
232
+ metadata: metadata,
233
+ retry_policy: @config.rpcs.enable_service.retry_policy
234
+ options.apply_defaults metadata: @config.metadata,
235
+ retry_policy: @config.retry_policy
236
+
237
+ @service_usage_stub.call_rpc :enable_service, request, options: options do |response, operation|
238
+ response = ::Gapic::Operation.new response, @operations_client, options: options
239
+ yield response, operation if block_given?
240
+ return response
241
+ end
242
+ rescue ::GRPC::BadStatus => e
243
+ raise ::Google::Cloud::Error.from_error(e)
244
+ end
245
+
246
+ ##
247
+ # Disable a service so that it can no longer be used with a project.
248
+ # This prevents unintended usage that may cause unexpected billing
249
+ # charges or security leaks.
250
+ #
251
+ # It is not valid to call the disable method on a service that is not
252
+ # currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
253
+ # the target service is not currently enabled.
254
+ #
255
+ # @overload disable_service(request, options = nil)
256
+ # Pass arguments to `disable_service` via a request object, either of type
257
+ # {::Google::Cloud::ServiceUsage::V1::DisableServiceRequest} or an equivalent Hash.
258
+ #
259
+ # @param request [::Google::Cloud::ServiceUsage::V1::DisableServiceRequest, ::Hash]
260
+ # A request object representing the call parameters. Required. To specify no
261
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
262
+ # @param options [::Gapic::CallOptions, ::Hash]
263
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
264
+ #
265
+ # @overload disable_service(name: nil, disable_dependent_services: nil, check_if_service_has_usage: nil)
266
+ # Pass arguments to `disable_service` via keyword arguments. Note that at
267
+ # least one keyword argument is required. To specify no parameters, or to keep all
268
+ # the default parameter values, pass an empty Hash as a request object (see above).
269
+ #
270
+ # @param name [::String]
271
+ # Name of the consumer and service to disable the service on.
272
+ #
273
+ # The enable and disable methods currently only support projects.
274
+ #
275
+ # An example name would be:
276
+ # `projects/123/services/serviceusage.googleapis.com` where `123` is the
277
+ # project number.
278
+ # @param disable_dependent_services [::Boolean]
279
+ # Indicates if services that are enabled and which depend on this service
280
+ # should also be disabled. If not set, an error will be generated if any
281
+ # enabled services depend on the service to be disabled. When set, the
282
+ # service, and any enabled services that depend on it, will be disabled
283
+ # together.
284
+ # @param check_if_service_has_usage [::Google::Cloud::ServiceUsage::V1::DisableServiceRequest::CheckIfServiceHasUsage]
285
+ # Defines the behavior for checking service usage when disabling a service.
286
+ #
287
+ # @yield [response, operation] Access the result along with the RPC operation
288
+ # @yieldparam response [::Gapic::Operation]
289
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
290
+ #
291
+ # @return [::Gapic::Operation]
292
+ #
293
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
294
+ #
295
+ def disable_service request, options = nil
296
+ raise ::ArgumentError, "request must be provided" if request.nil?
297
+
298
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::DisableServiceRequest
299
+
300
+ # Converts hash and nil to an options object
301
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
302
+
303
+ # Customize the options with defaults
304
+ metadata = @config.rpcs.disable_service.metadata.to_h
305
+
306
+ # Set x-goog-api-client and x-goog-user-project headers
307
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
308
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
309
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
310
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
311
+
312
+ header_params = {
313
+ "name" => request.name
314
+ }
315
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
316
+ metadata[:"x-goog-request-params"] ||= request_params_header
317
+
318
+ options.apply_defaults timeout: @config.rpcs.disable_service.timeout,
319
+ metadata: metadata,
320
+ retry_policy: @config.rpcs.disable_service.retry_policy
321
+ options.apply_defaults metadata: @config.metadata,
322
+ retry_policy: @config.retry_policy
323
+
324
+ @service_usage_stub.call_rpc :disable_service, request, options: options do |response, operation|
325
+ response = ::Gapic::Operation.new response, @operations_client, options: options
326
+ yield response, operation if block_given?
327
+ return response
328
+ end
329
+ rescue ::GRPC::BadStatus => e
330
+ raise ::Google::Cloud::Error.from_error(e)
331
+ end
332
+
333
+ ##
334
+ # Returns the service configuration and enabled state for a given service.
335
+ #
336
+ # @overload get_service(request, options = nil)
337
+ # Pass arguments to `get_service` via a request object, either of type
338
+ # {::Google::Cloud::ServiceUsage::V1::GetServiceRequest} or an equivalent Hash.
339
+ #
340
+ # @param request [::Google::Cloud::ServiceUsage::V1::GetServiceRequest, ::Hash]
341
+ # A request object representing the call parameters. Required. To specify no
342
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
343
+ # @param options [::Gapic::CallOptions, ::Hash]
344
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
345
+ #
346
+ # @overload get_service(name: nil)
347
+ # Pass arguments to `get_service` via keyword arguments. Note that at
348
+ # least one keyword argument is required. To specify no parameters, or to keep all
349
+ # the default parameter values, pass an empty Hash as a request object (see above).
350
+ #
351
+ # @param name [::String]
352
+ # Name of the consumer and service to get the `ConsumerState` for.
353
+ #
354
+ # An example name would be:
355
+ # `projects/123/services/serviceusage.googleapis.com` where `123` is the
356
+ # project number.
357
+ #
358
+ # @yield [response, operation] Access the result along with the RPC operation
359
+ # @yieldparam response [::Google::Cloud::ServiceUsage::V1::Service]
360
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
361
+ #
362
+ # @return [::Google::Cloud::ServiceUsage::V1::Service]
363
+ #
364
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
365
+ #
366
+ def get_service request, options = nil
367
+ raise ::ArgumentError, "request must be provided" if request.nil?
368
+
369
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::GetServiceRequest
370
+
371
+ # Converts hash and nil to an options object
372
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
373
+
374
+ # Customize the options with defaults
375
+ metadata = @config.rpcs.get_service.metadata.to_h
376
+
377
+ # Set x-goog-api-client and x-goog-user-project headers
378
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
379
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
380
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
381
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
382
+
383
+ header_params = {
384
+ "name" => request.name
385
+ }
386
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
387
+ metadata[:"x-goog-request-params"] ||= request_params_header
388
+
389
+ options.apply_defaults timeout: @config.rpcs.get_service.timeout,
390
+ metadata: metadata,
391
+ retry_policy: @config.rpcs.get_service.retry_policy
392
+ options.apply_defaults metadata: @config.metadata,
393
+ retry_policy: @config.retry_policy
394
+
395
+ @service_usage_stub.call_rpc :get_service, request, options: options do |response, operation|
396
+ yield response, operation if block_given?
397
+ return response
398
+ end
399
+ rescue ::GRPC::BadStatus => e
400
+ raise ::Google::Cloud::Error.from_error(e)
401
+ end
402
+
403
+ ##
404
+ # List all services available to the specified project, and the current
405
+ # state of those services with respect to the project. The list includes
406
+ # all public services, all services for which the calling user has the
407
+ # `servicemanagement.services.bind` permission, and all services that have
408
+ # already been enabled on the project. The list can be filtered to
409
+ # only include services in a specific state, for example to only include
410
+ # services enabled on the project.
411
+ #
412
+ # WARNING: If you need to query enabled services frequently or across
413
+ # an organization, you should use
414
+ # [Cloud Asset Inventory
415
+ # API](https://cloud.google.com/asset-inventory/docs/apis), which provides
416
+ # higher throughput and richer filtering capability.
417
+ #
418
+ # @overload list_services(request, options = nil)
419
+ # Pass arguments to `list_services` via a request object, either of type
420
+ # {::Google::Cloud::ServiceUsage::V1::ListServicesRequest} or an equivalent Hash.
421
+ #
422
+ # @param request [::Google::Cloud::ServiceUsage::V1::ListServicesRequest, ::Hash]
423
+ # A request object representing the call parameters. Required. To specify no
424
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
425
+ # @param options [::Gapic::CallOptions, ::Hash]
426
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
427
+ #
428
+ # @overload list_services(parent: nil, page_size: nil, page_token: nil, filter: nil)
429
+ # Pass arguments to `list_services` via keyword arguments. Note that at
430
+ # least one keyword argument is required. To specify no parameters, or to keep all
431
+ # the default parameter values, pass an empty Hash as a request object (see above).
432
+ #
433
+ # @param parent [::String]
434
+ # Parent to search for services on.
435
+ #
436
+ # An example name would be:
437
+ # `projects/123` where `123` is the project number.
438
+ # @param page_size [::Integer]
439
+ # Requested size of the next page of data.
440
+ # Requested page size cannot exceed 200.
441
+ # If not set, the default page size is 50.
442
+ # @param page_token [::String]
443
+ # Token identifying which result to start with, which is returned by a
444
+ # previous list call.
445
+ # @param filter [::String]
446
+ # Only list services that conform to the given filter.
447
+ # The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
448
+ #
449
+ # @yield [response, operation] Access the result along with the RPC operation
450
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>]
451
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
452
+ #
453
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::ServiceUsage::V1::Service>]
454
+ #
455
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
456
+ #
457
+ def list_services request, options = nil
458
+ raise ::ArgumentError, "request must be provided" if request.nil?
459
+
460
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::ListServicesRequest
461
+
462
+ # Converts hash and nil to an options object
463
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
464
+
465
+ # Customize the options with defaults
466
+ metadata = @config.rpcs.list_services.metadata.to_h
467
+
468
+ # Set x-goog-api-client and x-goog-user-project headers
469
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
470
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
471
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
472
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
473
+
474
+ header_params = {
475
+ "parent" => request.parent
476
+ }
477
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
478
+ metadata[:"x-goog-request-params"] ||= request_params_header
479
+
480
+ options.apply_defaults timeout: @config.rpcs.list_services.timeout,
481
+ metadata: metadata,
482
+ retry_policy: @config.rpcs.list_services.retry_policy
483
+ options.apply_defaults metadata: @config.metadata,
484
+ retry_policy: @config.retry_policy
485
+
486
+ @service_usage_stub.call_rpc :list_services, request, options: options do |response, operation|
487
+ response = ::Gapic::PagedEnumerable.new @service_usage_stub, :list_services, request, response, operation, options
488
+ yield response, operation if block_given?
489
+ return response
490
+ end
491
+ rescue ::GRPC::BadStatus => e
492
+ raise ::Google::Cloud::Error.from_error(e)
493
+ end
494
+
495
+ ##
496
+ # Enable multiple services on a project. The operation is atomic: if enabling
497
+ # any service fails, then the entire batch fails, and no state changes occur.
498
+ # To enable a single service, use the `EnableService` method instead.
499
+ #
500
+ # @overload batch_enable_services(request, options = nil)
501
+ # Pass arguments to `batch_enable_services` via a request object, either of type
502
+ # {::Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest} or an equivalent Hash.
503
+ #
504
+ # @param request [::Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest, ::Hash]
505
+ # A request object representing the call parameters. Required. To specify no
506
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
507
+ # @param options [::Gapic::CallOptions, ::Hash]
508
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
509
+ #
510
+ # @overload batch_enable_services(parent: nil, service_ids: nil)
511
+ # Pass arguments to `batch_enable_services` via keyword arguments. Note that at
512
+ # least one keyword argument is required. To specify no parameters, or to keep all
513
+ # the default parameter values, pass an empty Hash as a request object (see above).
514
+ #
515
+ # @param parent [::String]
516
+ # Parent to enable services on.
517
+ #
518
+ # An example name would be:
519
+ # `projects/123` where `123` is the project number.
520
+ #
521
+ # The `BatchEnableServices` method currently only supports projects.
522
+ # @param service_ids [::Array<::String>]
523
+ # The identifiers of the services to enable on the project.
524
+ #
525
+ # A valid identifier would be:
526
+ # serviceusage.googleapis.com
527
+ #
528
+ # Enabling services requires that each service is public or is shared with
529
+ # the user enabling the service.
530
+ #
531
+ # A single request can enable a maximum of 20 services at a time. If more
532
+ # than 20 services are specified, the request will fail, and no state changes
533
+ # will occur.
534
+ #
535
+ # @yield [response, operation] Access the result along with the RPC operation
536
+ # @yieldparam response [::Gapic::Operation]
537
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
538
+ #
539
+ # @return [::Gapic::Operation]
540
+ #
541
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
542
+ #
543
+ def batch_enable_services request, options = nil
544
+ raise ::ArgumentError, "request must be provided" if request.nil?
545
+
546
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::BatchEnableServicesRequest
547
+
548
+ # Converts hash and nil to an options object
549
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
550
+
551
+ # Customize the options with defaults
552
+ metadata = @config.rpcs.batch_enable_services.metadata.to_h
553
+
554
+ # Set x-goog-api-client and x-goog-user-project headers
555
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
556
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
557
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
558
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
559
+
560
+ header_params = {
561
+ "parent" => request.parent
562
+ }
563
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
564
+ metadata[:"x-goog-request-params"] ||= request_params_header
565
+
566
+ options.apply_defaults timeout: @config.rpcs.batch_enable_services.timeout,
567
+ metadata: metadata,
568
+ retry_policy: @config.rpcs.batch_enable_services.retry_policy
569
+ options.apply_defaults metadata: @config.metadata,
570
+ retry_policy: @config.retry_policy
571
+
572
+ @service_usage_stub.call_rpc :batch_enable_services, request, options: options do |response, operation|
573
+ response = ::Gapic::Operation.new response, @operations_client, options: options
574
+ yield response, operation if block_given?
575
+ return response
576
+ end
577
+ rescue ::GRPC::BadStatus => e
578
+ raise ::Google::Cloud::Error.from_error(e)
579
+ end
580
+
581
+ ##
582
+ # Returns the service configurations and enabled states for a given list of
583
+ # services.
584
+ #
585
+ # @overload batch_get_services(request, options = nil)
586
+ # Pass arguments to `batch_get_services` via a request object, either of type
587
+ # {::Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest} or an equivalent Hash.
588
+ #
589
+ # @param request [::Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest, ::Hash]
590
+ # A request object representing the call parameters. Required. To specify no
591
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
592
+ # @param options [::Gapic::CallOptions, ::Hash]
593
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
594
+ #
595
+ # @overload batch_get_services(parent: nil, names: nil)
596
+ # Pass arguments to `batch_get_services` via keyword arguments. Note that at
597
+ # least one keyword argument is required. To specify no parameters, or to keep all
598
+ # the default parameter values, pass an empty Hash as a request object (see above).
599
+ #
600
+ # @param parent [::String]
601
+ # Parent to retrieve services from.
602
+ # If this is set, the parent of all of the services specified in `names` must
603
+ # match this field. An example name would be: `projects/123` where `123` is
604
+ # the project number. The `BatchGetServices` method currently only supports
605
+ # projects.
606
+ # @param names [::Array<::String>]
607
+ # Names of the services to retrieve.
608
+ #
609
+ # An example name would be:
610
+ # `projects/123/services/serviceusage.googleapis.com` where `123` is the
611
+ # project number.
612
+ # A single request can get a maximum of 30 services at a time.
613
+ #
614
+ # @yield [response, operation] Access the result along with the RPC operation
615
+ # @yieldparam response [::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse]
616
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
617
+ #
618
+ # @return [::Google::Cloud::ServiceUsage::V1::BatchGetServicesResponse]
619
+ #
620
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
621
+ #
622
+ def batch_get_services request, options = nil
623
+ raise ::ArgumentError, "request must be provided" if request.nil?
624
+
625
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceUsage::V1::BatchGetServicesRequest
626
+
627
+ # Converts hash and nil to an options object
628
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
629
+
630
+ # Customize the options with defaults
631
+ metadata = @config.rpcs.batch_get_services.metadata.to_h
632
+
633
+ # Set x-goog-api-client and x-goog-user-project headers
634
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
635
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
636
+ gapic_version: ::Google::Cloud::ServiceUsage::V1::VERSION
637
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
638
+
639
+ header_params = {
640
+ "parent" => request.parent
641
+ }
642
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
643
+ metadata[:"x-goog-request-params"] ||= request_params_header
644
+
645
+ options.apply_defaults timeout: @config.rpcs.batch_get_services.timeout,
646
+ metadata: metadata,
647
+ retry_policy: @config.rpcs.batch_get_services.retry_policy
648
+ options.apply_defaults metadata: @config.metadata,
649
+ retry_policy: @config.retry_policy
650
+
651
+ @service_usage_stub.call_rpc :batch_get_services, request, options: options do |response, operation|
652
+ yield response, operation if block_given?
653
+ return response
654
+ end
655
+ rescue ::GRPC::BadStatus => e
656
+ raise ::Google::Cloud::Error.from_error(e)
657
+ end
658
+
659
+ ##
660
+ # Configuration class for the ServiceUsage API.
661
+ #
662
+ # This class represents the configuration for ServiceUsage,
663
+ # providing control over timeouts, retry behavior, logging, transport
664
+ # parameters, and other low-level controls. Certain parameters can also be
665
+ # applied individually to specific RPCs. See
666
+ # {::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client::Configuration::Rpcs}
667
+ # for a list of RPCs that can be configured independently.
668
+ #
669
+ # Configuration can be applied globally to all clients, or to a single client
670
+ # on construction.
671
+ #
672
+ # # Examples
673
+ #
674
+ # To modify the global config, setting the timeout for enable_service
675
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
676
+ #
677
+ # ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.configure do |config|
678
+ # config.timeout = 10.0
679
+ # config.rpcs.enable_service.timeout = 20.0
680
+ # end
681
+ #
682
+ # To apply the above configuration only to a new client:
683
+ #
684
+ # client = ::Google::Cloud::ServiceUsage::V1::ServiceUsage::Client.new do |config|
685
+ # config.timeout = 10.0
686
+ # config.rpcs.enable_service.timeout = 20.0
687
+ # end
688
+ #
689
+ # @!attribute [rw] endpoint
690
+ # The hostname or hostname:port of the service endpoint.
691
+ # Defaults to `"serviceusage.googleapis.com"`.
692
+ # @return [::String]
693
+ # @!attribute [rw] credentials
694
+ # Credentials to send with calls. You may provide any of the following types:
695
+ # * (`String`) The path to a service account key file in JSON format
696
+ # * (`Hash`) A service account key as a Hash
697
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
698
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
699
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
700
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
701
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
702
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
703
+ # * (`nil`) indicating no credentials
704
+ # @return [::Object]
705
+ # @!attribute [rw] scope
706
+ # The OAuth scopes
707
+ # @return [::Array<::String>]
708
+ # @!attribute [rw] lib_name
709
+ # The library name as recorded in instrumentation and logging
710
+ # @return [::String]
711
+ # @!attribute [rw] lib_version
712
+ # The library version as recorded in instrumentation and logging
713
+ # @return [::String]
714
+ # @!attribute [rw] channel_args
715
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
716
+ # `GRPC::Core::Channel` object is provided as the credential.
717
+ # @return [::Hash]
718
+ # @!attribute [rw] interceptors
719
+ # An array of interceptors that are run before calls are executed.
720
+ # @return [::Array<::GRPC::ClientInterceptor>]
721
+ # @!attribute [rw] timeout
722
+ # The call timeout in seconds.
723
+ # @return [::Numeric]
724
+ # @!attribute [rw] metadata
725
+ # Additional gRPC headers to be sent with the call.
726
+ # @return [::Hash{::Symbol=>::String}]
727
+ # @!attribute [rw] retry_policy
728
+ # The retry policy. The value is a hash with the following keys:
729
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
730
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
731
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
732
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
733
+ # trigger a retry.
734
+ # @return [::Hash]
735
+ # @!attribute [rw] quota_project
736
+ # A separate project against which to charge quota.
737
+ # @return [::String]
738
+ #
739
+ class Configuration
740
+ extend ::Gapic::Config
741
+
742
+ config_attr :endpoint, "serviceusage.googleapis.com", ::String
743
+ config_attr :credentials, nil do |value|
744
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
745
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
746
+ allowed.any? { |klass| klass === value }
747
+ end
748
+ config_attr :scope, nil, ::String, ::Array, nil
749
+ config_attr :lib_name, nil, ::String, nil
750
+ config_attr :lib_version, nil, ::String, nil
751
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
752
+ config_attr :interceptors, nil, ::Array, nil
753
+ config_attr :timeout, nil, ::Numeric, nil
754
+ config_attr :metadata, nil, ::Hash, nil
755
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
756
+ config_attr :quota_project, nil, ::String, nil
757
+
758
+ # @private
759
+ def initialize parent_config = nil
760
+ @parent_config = parent_config unless parent_config.nil?
761
+
762
+ yield self if block_given?
763
+ end
764
+
765
+ ##
766
+ # Configurations for individual RPCs
767
+ # @return [Rpcs]
768
+ #
769
+ def rpcs
770
+ @rpcs ||= begin
771
+ parent_rpcs = nil
772
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
773
+ Rpcs.new parent_rpcs
774
+ end
775
+ end
776
+
777
+ ##
778
+ # Configuration RPC class for the ServiceUsage API.
779
+ #
780
+ # Includes fields providing the configuration for each RPC in this service.
781
+ # Each configuration object is of type `Gapic::Config::Method` and includes
782
+ # the following configuration fields:
783
+ #
784
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
785
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
786
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
787
+ # include the following keys:
788
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
789
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
790
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
791
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
792
+ # trigger a retry.
793
+ #
794
+ class Rpcs
795
+ ##
796
+ # RPC-specific configuration for `enable_service`
797
+ # @return [::Gapic::Config::Method]
798
+ #
799
+ attr_reader :enable_service
800
+ ##
801
+ # RPC-specific configuration for `disable_service`
802
+ # @return [::Gapic::Config::Method]
803
+ #
804
+ attr_reader :disable_service
805
+ ##
806
+ # RPC-specific configuration for `get_service`
807
+ # @return [::Gapic::Config::Method]
808
+ #
809
+ attr_reader :get_service
810
+ ##
811
+ # RPC-specific configuration for `list_services`
812
+ # @return [::Gapic::Config::Method]
813
+ #
814
+ attr_reader :list_services
815
+ ##
816
+ # RPC-specific configuration for `batch_enable_services`
817
+ # @return [::Gapic::Config::Method]
818
+ #
819
+ attr_reader :batch_enable_services
820
+ ##
821
+ # RPC-specific configuration for `batch_get_services`
822
+ # @return [::Gapic::Config::Method]
823
+ #
824
+ attr_reader :batch_get_services
825
+
826
+ # @private
827
+ def initialize parent_rpcs = nil
828
+ enable_service_config = parent_rpcs.enable_service if parent_rpcs.respond_to? :enable_service
829
+ @enable_service = ::Gapic::Config::Method.new enable_service_config
830
+ disable_service_config = parent_rpcs.disable_service if parent_rpcs.respond_to? :disable_service
831
+ @disable_service = ::Gapic::Config::Method.new disable_service_config
832
+ get_service_config = parent_rpcs.get_service if parent_rpcs.respond_to? :get_service
833
+ @get_service = ::Gapic::Config::Method.new get_service_config
834
+ list_services_config = parent_rpcs.list_services if parent_rpcs.respond_to? :list_services
835
+ @list_services = ::Gapic::Config::Method.new list_services_config
836
+ batch_enable_services_config = parent_rpcs.batch_enable_services if parent_rpcs.respond_to? :batch_enable_services
837
+ @batch_enable_services = ::Gapic::Config::Method.new batch_enable_services_config
838
+ batch_get_services_config = parent_rpcs.batch_get_services if parent_rpcs.respond_to? :batch_get_services
839
+ @batch_get_services = ::Gapic::Config::Method.new batch_get_services_config
840
+
841
+ yield self if block_given?
842
+ end
843
+ end
844
+ end
845
+ end
846
+ end
847
+ end
848
+ end
849
+ end
850
+ end