google-ads-googleads 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +8 -0
  3. data/google_ads_config.rb +6 -0
  4. data/lib/google/ads/google_ads/api_versions.rb +8 -0
  5. data/lib/google/ads/google_ads/config.rb +2 -0
  6. data/lib/google/ads/google_ads/google_ads_client.rb +37 -66
  7. data/lib/google/ads/google_ads/logging_interceptor.rb +108 -36
  8. data/lib/google/ads/google_ads/lookup_util.rb +105 -0
  9. data/lib/google/ads/google_ads/partial_failure_error_decoder.rb +24 -0
  10. data/lib/google/ads/google_ads/utils/v0/proto_lookup_util.rb +4 -1
  11. data/lib/google/ads/google_ads/utils/v1/path_lookup_util.rb +11 -1
  12. data/lib/google/ads/google_ads/utils/v1/proto_lookup_util.rb +39 -6
  13. data/lib/google/ads/google_ads/v1/common/ad_asset_pb.rb +12 -0
  14. data/lib/google/ads/google_ads/v1/common/ad_type_infos_pb.rb +39 -0
  15. data/lib/google/ads/google_ads/v1/common/asset_types_pb.rb +34 -0
  16. data/lib/google/ads/google_ads/v1/common/bidding_pb.rb +4 -0
  17. data/lib/google/ads/google_ads/v1/common/criteria_pb.rb +4 -0
  18. data/lib/google/ads/google_ads/v1/common/policy_pb.rb +1 -0
  19. data/lib/google/ads/google_ads/v1/common/segments_pb.rb +2 -0
  20. data/lib/google/ads/google_ads/v1/enums/ad_group_criterion_approval_status_pb.rb +23 -0
  21. data/lib/google/ads/google_ads/v1/enums/ad_group_type_pb.rb +1 -0
  22. data/lib/google/ads/google_ads/v1/enums/ad_type_pb.rb +3 -0
  23. data/lib/google/ads/google_ads/v1/enums/advertising_channel_sub_type_pb.rb +1 -0
  24. data/lib/google/ads/google_ads/v1/enums/advertising_channel_type_pb.rb +1 -0
  25. data/lib/google/ads/google_ads/v1/enums/app_campaign_app_store_pb.rb +21 -0
  26. data/lib/google/ads/google_ads/v1/enums/app_campaign_bidding_strategy_goal_type_pb.rb +23 -0
  27. data/lib/google/ads/google_ads/v1/enums/asset_type_pb.rb +22 -0
  28. data/lib/google/ads/google_ads/v1/enums/bidding_source_pb.rb +2 -2
  29. data/lib/google/ads/google_ads/v1/enums/budget_type_pb.rb +21 -0
  30. data/lib/google/ads/google_ads/v1/enums/conversion_adjustment_type_pb.rb +21 -0
  31. data/lib/google/ads/google_ads/v1/enums/legacy_app_install_ad_app_store_pb.rb +24 -0
  32. data/lib/google/ads/google_ads/v1/enums/payment_mode_pb.rb +21 -0
  33. data/lib/google/ads/google_ads/v1/enums/recommendation_type_pb.rb +2 -0
  34. data/lib/google/ads/google_ads/v1/errors/asset_error_pb.rb +23 -0
  35. data/lib/google/ads/google_ads/v1/errors/authorization_error_pb.rb +2 -0
  36. data/lib/google/ads/google_ads/v1/errors/bidding_error_pb.rb +1 -0
  37. data/lib/google/ads/google_ads/v1/errors/campaign_error_pb.rb +1 -0
  38. data/lib/google/ads/google_ads/v1/errors/conversion_adjustment_upload_error_pb.rb +28 -0
  39. data/lib/google/ads/google_ads/v1/errors/conversion_upload_error_pb.rb +6 -0
  40. data/lib/google/ads/google_ads/v1/errors/criterion_error_pb.rb +2 -0
  41. data/lib/google/ads/google_ads/v1/errors/errors_pb.rb +4 -0
  42. data/lib/google/ads/google_ads/v1/errors/media_upload_error_pb.rb +11 -0
  43. data/lib/google/ads/google_ads/v1/errors/mutate_error_pb.rb +1 -0
  44. data/lib/google/ads/google_ads/v1/errors/policy_validation_parameter_error_pb.rb +2 -0
  45. data/lib/google/ads/google_ads/v1/errors/recommendation_error_pb.rb +1 -0
  46. data/lib/google/ads/google_ads/v1/errors/request_error_pb.rb +1 -0
  47. data/lib/google/ads/google_ads/v1/errors/youtube_video_registration_error_pb.rb +11 -0
  48. data/lib/google/ads/google_ads/v1/resources/ad_group_criterion_pb.rb +3 -0
  49. data/lib/google/ads/google_ads/v1/resources/ad_pb.rb +3 -0
  50. data/lib/google/ads/google_ads/v1/resources/asset_pb.rb +26 -0
  51. data/lib/google/ads/google_ads/v1/resources/campaign_budget_pb.rb +2 -0
  52. data/lib/google/ads/google_ads/v1/resources/campaign_criterion_pb.rb +1 -0
  53. data/lib/google/ads/google_ads/v1/resources/campaign_pb.rb +23 -11
  54. data/lib/google/ads/google_ads/v1/resources/extension_feed_item_pb.rb +2 -0
  55. data/lib/google/ads/google_ads/v1/resources/mutate_job_pb.rb +2 -0
  56. data/lib/google/ads/google_ads/v1/resources/recommendation_pb.rb +21 -8
  57. data/lib/google/ads/google_ads/v1/resources/shared_criterion_pb.rb +1 -0
  58. data/lib/google/ads/google_ads/v1/services/ad_group_criterion_service_pb.rb +2 -0
  59. data/lib/google/ads/google_ads/v1/services/asset_service_client.rb +267 -0
  60. data/lib/google/ads/google_ads/v1/services/asset_service_client_config.json +36 -0
  61. data/lib/google/ads/google_ads/v1/services/asset_service_pb.rb +35 -0
  62. data/lib/google/ads/google_ads/v1/services/asset_service_services_pb.rb +42 -0
  63. data/lib/google/ads/google_ads/v1/services/conversion_adjustment_upload_service_client.rb +222 -0
  64. data/lib/google/ads/google_ads/v1/services/conversion_adjustment_upload_service_client_config.json +31 -0
  65. data/lib/google/ads/google_ads/v1/services/conversion_adjustment_upload_service_pb.rb +56 -0
  66. data/lib/google/ads/google_ads/v1/services/conversion_adjustment_upload_service_services_pb.rb +40 -0
  67. data/lib/google/ads/google_ads/v1/services/conversion_upload_service_client.rb +53 -0
  68. data/lib/google/ads/google_ads/v1/services/conversion_upload_service_client_config.json +5 -0
  69. data/lib/google/ads/google_ads/v1/services/conversion_upload_service_pb.rb +27 -0
  70. data/lib/google/ads/google_ads/v1/services/conversion_upload_service_services_pb.rb +2 -0
  71. data/lib/google/ads/google_ads/v1/services/google_ads_service_pb.rb +5 -0
  72. data/lib/google/ads/google_ads/v1/services/recommendation_service_pb.rb +5 -0
  73. data/lib/google/ads/google_ads/v1/services/shopping_performance_view_service_client.rb +19 -6
  74. data/lib/google/ads/google_ads/version.rb +1 -1
  75. data/lib/google/ads/google_ads/wrapper_util.rb +4 -0
  76. data/lib/google/ads/google_ads.rb +4 -0
  77. metadata +27 -2
@@ -0,0 +1,267 @@
1
+ # Copyright 2019 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/ads/google_ads/v1/services/asset_service.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/ads/google_ads/v1/services/asset_service_pb"
28
+ require "google/ads/google_ads/v1/services/credentials"
29
+
30
+ module Google
31
+ module Ads
32
+ module GoogleAds
33
+ module V1
34
+ module Services
35
+ # Service to manage assets.
36
+ #
37
+ # @!attribute [r] asset_service_stub
38
+ # @return [Google::Ads::GoogleAds::V1::Services::AssetService::Stub]
39
+ class AssetServiceClient
40
+ attr_reader :asset_service_stub
41
+
42
+ # The default address of the service.
43
+ SERVICE_ADDRESS = "googleads.googleapis.com".freeze
44
+
45
+ # The default port of the service.
46
+ DEFAULT_SERVICE_PORT = 443
47
+
48
+ # The default set of gRPC interceptors.
49
+ GRPC_INTERCEPTORS = []
50
+
51
+ DEFAULT_TIMEOUT = 30
52
+
53
+ # The scopes needed to make gRPC calls to all of the methods defined in
54
+ # this service.
55
+ ALL_SCOPES = [
56
+ ].freeze
57
+
58
+
59
+ ASSET_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
60
+ "customers/{customer}/assets/{asset}"
61
+ )
62
+
63
+ private_constant :ASSET_PATH_TEMPLATE
64
+
65
+ # Returns a fully-qualified asset resource name string.
66
+ # @param customer [String]
67
+ # @param asset [String]
68
+ # @return [String]
69
+ def self.asset_path customer, asset
70
+ ASSET_PATH_TEMPLATE.render(
71
+ :"customer" => customer,
72
+ :"asset" => asset
73
+ )
74
+ end
75
+
76
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
77
+ # Provides the means for authenticating requests made by the client. This parameter can
78
+ # be many types.
79
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
80
+ # authenticating requests made by this client.
81
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
82
+ # credentials for this client.
83
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
84
+ # credentials for this client.
85
+ # A `GRPC::Core::Channel` will be used to make calls through.
86
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
87
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
88
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
89
+ # metadata for requests, generally, to give OAuth credentials.
90
+ # @param scopes [Array<String>]
91
+ # The OAuth scopes for this service. This parameter is ignored if
92
+ # an updater_proc is supplied.
93
+ # @param client_config [Hash]
94
+ # A Hash for call options for each method. See
95
+ # Google::Gax#construct_settings for the structure of
96
+ # this data. Falls back to the default config if not specified
97
+ # or the specified config is missing data points.
98
+ # @param timeout [Numeric]
99
+ # The default timeout, in seconds, for calls made through this client.
100
+ # @param metadata [Hash]
101
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
102
+ # @param exception_transformer [Proc]
103
+ # An optional proc that intercepts any exceptions raised during an API call to inject
104
+ # custom error handling.
105
+ def initialize \
106
+ credentials: nil,
107
+ scopes: ALL_SCOPES,
108
+ client_config: {},
109
+ timeout: DEFAULT_TIMEOUT,
110
+ metadata: nil,
111
+ exception_transformer: nil,
112
+ lib_name: nil,
113
+ lib_version: ""
114
+ # These require statements are intentionally placed here to initialize
115
+ # the gRPC module only when it's required.
116
+ # See https://github.com/googleapis/toolkit/issues/446
117
+ require "google/gax/grpc"
118
+ require "google/ads/google_ads/v1/services/asset_service_services_pb"
119
+
120
+ credentials ||= Google::Ads::GoogleAds::V1::Services::Credentials.default
121
+
122
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
123
+ updater_proc = Google::Ads::GoogleAds::V1::Services::Credentials.new(credentials).updater_proc
124
+ end
125
+ if credentials.is_a?(GRPC::Core::Channel)
126
+ channel = credentials
127
+ end
128
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
129
+ chan_creds = credentials
130
+ end
131
+ if credentials.is_a?(Proc)
132
+ updater_proc = credentials
133
+ end
134
+ if credentials.is_a?(Google::Auth::Credentials)
135
+ updater_proc = credentials.updater_proc
136
+ end
137
+
138
+ package_version = Gem.loaded_specs['google-ads-googleads'].version.version
139
+
140
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
141
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
142
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
143
+ google_api_client << " grpc/#{GRPC::VERSION}"
144
+ google_api_client.freeze
145
+
146
+ headers = { :"x-goog-api-client" => google_api_client }
147
+ headers.merge!(metadata) unless metadata.nil?
148
+ client_config_file = Pathname.new(__dir__).join(
149
+ "asset_service_client_config.json"
150
+ )
151
+ defaults = client_config_file.open do |f|
152
+ Google::Gax.construct_settings(
153
+ "google.ads.googleads.v1.services.AssetService",
154
+ JSON.parse(f.read),
155
+ client_config,
156
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
157
+ timeout,
158
+ errors: Google::Gax::Grpc::API_ERRORS,
159
+ metadata: headers
160
+ )
161
+ end
162
+
163
+ # Allow overriding the service path/port in subclasses.
164
+ service_path = self.class::SERVICE_ADDRESS
165
+ port = self.class::DEFAULT_SERVICE_PORT
166
+ interceptors = self.class::GRPC_INTERCEPTORS
167
+ @asset_service_stub = Google::Gax::Grpc.create_stub(
168
+ service_path,
169
+ port,
170
+ chan_creds: chan_creds,
171
+ channel: channel,
172
+ updater_proc: updater_proc,
173
+ scopes: scopes,
174
+ interceptors: interceptors,
175
+ &Google::Ads::GoogleAds::V1::Services::AssetService::Stub.method(:new)
176
+ )
177
+
178
+ @get_asset = Google::Gax.create_api_call(
179
+ @asset_service_stub.method(:get_asset),
180
+ defaults["get_asset"],
181
+ exception_transformer: exception_transformer
182
+ )
183
+ @mutate_assets = Google::Gax.create_api_call(
184
+ @asset_service_stub.method(:mutate_assets),
185
+ defaults["mutate_assets"],
186
+ exception_transformer: exception_transformer
187
+ )
188
+ end
189
+
190
+ # Service calls
191
+
192
+ # Returns the requested asset in full detail.
193
+ #
194
+ # @param resource_name [String]
195
+ # The resource name of the asset to fetch.
196
+ # @param options [Google::Gax::CallOptions]
197
+ # Overrides the default settings for this call, e.g, timeout,
198
+ # retries, etc.
199
+ # @yield [result, operation] Access the result along with the RPC operation
200
+ # @yieldparam result [Google::Ads::GoogleAds::V1::Resources::Asset]
201
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
202
+ # @return [Google::Ads::GoogleAds::V1::Resources::Asset]
203
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
204
+ # @example
205
+ # require "google/ads/google_ads"
206
+ #
207
+ # asset_service_client = Google::Ads::GoogleAds::Asset.new(version: :v1)
208
+ # formatted_resource_name = Google::Ads::GoogleAds::V1::Services::AssetServiceClient.asset_path("[CUSTOMER]", "[ASSET]")
209
+ # response = asset_service_client.get_asset(formatted_resource_name)
210
+
211
+ def get_asset \
212
+ resource_name,
213
+ options: nil,
214
+ &block
215
+ req = {
216
+ resource_name: resource_name
217
+ }.delete_if { |_, v| v.nil? }
218
+ req = Google::Gax::to_proto(req, Google::Ads::GoogleAds::V1::Services::GetAssetRequest)
219
+ @get_asset.call(req, options, &block)
220
+ end
221
+
222
+ # Creates assets. Operation statuses are returned.
223
+ #
224
+ # @param customer_id [String]
225
+ # The ID of the customer whose assets are being modified.
226
+ # @param operations [Array<Google::Ads::GoogleAds::V1::Services::AssetOperation | Hash>]
227
+ # The list of operations to perform on individual assets.
228
+ # A hash of the same form as `Google::Ads::GoogleAds::V1::Services::AssetOperation`
229
+ # can also be provided.
230
+ # @param options [Google::Gax::CallOptions]
231
+ # Overrides the default settings for this call, e.g, timeout,
232
+ # retries, etc.
233
+ # @yield [result, operation] Access the result along with the RPC operation
234
+ # @yieldparam result [Google::Ads::GoogleAds::V1::Services::MutateAssetsResponse]
235
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
236
+ # @return [Google::Ads::GoogleAds::V1::Services::MutateAssetsResponse]
237
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
238
+ # @example
239
+ # require "google/ads/google_ads"
240
+ #
241
+ # asset_service_client = Google::Ads::GoogleAds::Asset.new(version: :v1)
242
+ #
243
+ # # TODO: Initialize `customer_id`:
244
+ # customer_id = ''
245
+ #
246
+ # # TODO: Initialize `operations`:
247
+ # operations = []
248
+ # response = asset_service_client.mutate_assets(customer_id, operations)
249
+
250
+ def mutate_assets \
251
+ customer_id,
252
+ operations,
253
+ options: nil,
254
+ &block
255
+ req = {
256
+ customer_id: customer_id,
257
+ operations: operations
258
+ }.delete_if { |_, v| v.nil? }
259
+ req = Google::Gax::to_proto(req, Google::Ads::GoogleAds::V1::Services::MutateAssetsRequest)
260
+ @mutate_assets.call(req, options, &block)
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end
@@ -0,0 +1,36 @@
1
+ {
2
+ "interfaces": {
3
+ "google.ads.googleads.v1.services.AssetService": {
4
+ "retry_codes": {
5
+ "idempotent": [
6
+ "DEADLINE_EXCEEDED",
7
+ "UNAVAILABLE"
8
+ ],
9
+ "non_idempotent": []
10
+ },
11
+ "retry_params": {
12
+ "default": {
13
+ "initial_retry_delay_millis": 100,
14
+ "retry_delay_multiplier": 1.3,
15
+ "max_retry_delay_millis": 60000,
16
+ "initial_rpc_timeout_millis": 20000,
17
+ "rpc_timeout_multiplier": 1.0,
18
+ "max_rpc_timeout_millis": 20000,
19
+ "total_timeout_millis": 600000
20
+ }
21
+ },
22
+ "methods": {
23
+ "GetAsset": {
24
+ "timeout_millis": 60000,
25
+ "retry_codes_name": "idempotent",
26
+ "retry_params_name": "default"
27
+ },
28
+ "MutateAssets": {
29
+ "timeout_millis": 60000,
30
+ "retry_codes_name": "non_idempotent",
31
+ "retry_params_name": "default"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,35 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/ads/google_ads/v1/services/asset_service.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/ads/google_ads/v1/resources/asset_pb'
7
+ require 'google/api/annotations_pb'
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_message "google.ads.googleads.v1.services.GetAssetRequest" do
10
+ optional :resource_name, :string, 1
11
+ end
12
+ add_message "google.ads.googleads.v1.services.MutateAssetsRequest" do
13
+ optional :customer_id, :string, 1
14
+ repeated :operations, :message, 2, "google.ads.googleads.v1.services.AssetOperation"
15
+ end
16
+ add_message "google.ads.googleads.v1.services.AssetOperation" do
17
+ oneof :operation do
18
+ optional :create, :message, 1, "google.ads.googleads.v1.resources.Asset"
19
+ end
20
+ end
21
+ add_message "google.ads.googleads.v1.services.MutateAssetsResponse" do
22
+ repeated :results, :message, 2, "google.ads.googleads.v1.services.MutateAssetResult"
23
+ end
24
+ add_message "google.ads.googleads.v1.services.MutateAssetResult" do
25
+ optional :resource_name, :string, 1
26
+ end
27
+ end
28
+
29
+ module Google::Ads::GoogleAds::V1::Services
30
+ GetAssetRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v1.services.GetAssetRequest").msgclass
31
+ MutateAssetsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v1.services.MutateAssetsRequest").msgclass
32
+ AssetOperation = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v1.services.AssetOperation").msgclass
33
+ MutateAssetsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v1.services.MutateAssetsResponse").msgclass
34
+ MutateAssetResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v1.services.MutateAssetResult").msgclass
35
+ end
@@ -0,0 +1,42 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/ads/google_ads/v1/services/asset_service.proto for package 'Google::Ads::GoogleAds::V1::Services'
3
+ # Original file comments:
4
+ # Copyright 2019 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
+
20
+ require 'grpc'
21
+ require 'google/ads/google_ads/v1/services/asset_service_pb'
22
+
23
+ module Google::Ads::GoogleAds::V1::Services
24
+ module AssetService
25
+ # Service to manage assets.
26
+ class Service
27
+
28
+ include GRPC::GenericService
29
+
30
+ self.marshal_class_method = :encode
31
+ self.unmarshal_class_method = :decode
32
+ self.service_name = 'google.ads.googleads.v1.services.AssetService'
33
+
34
+ # Returns the requested asset in full detail.
35
+ rpc :GetAsset, GetAssetRequest, Google::Ads::GoogleAds::V1::Resources::Asset
36
+ # Creates assets. Operation statuses are returned.
37
+ rpc :MutateAssets, MutateAssetsRequest, MutateAssetsResponse
38
+ end
39
+
40
+ Stub = Service.rpc_stub_class
41
+ end
42
+ end
@@ -0,0 +1,222 @@
1
+ # Copyright 2019 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/ads/google_ads/v1/services/conversion_adjustment_upload_service.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/ads/google_ads/v1/services/conversion_adjustment_upload_service_pb"
28
+ require "google/ads/google_ads/v1/services/credentials"
29
+
30
+ module Google
31
+ module Ads
32
+ module GoogleAds
33
+ module V1
34
+ module Services
35
+ # Service to upload conversion adjustments.
36
+ #
37
+ # @!attribute [r] conversion_adjustment_upload_service_stub
38
+ # @return [Google::Ads::GoogleAds::V1::Services::ConversionAdjustmentUploadService::Stub]
39
+ class ConversionAdjustmentUploadServiceClient
40
+ attr_reader :conversion_adjustment_upload_service_stub
41
+
42
+ # The default address of the service.
43
+ SERVICE_ADDRESS = "googleads.googleapis.com".freeze
44
+
45
+ # The default port of the service.
46
+ DEFAULT_SERVICE_PORT = 443
47
+
48
+ # The default set of gRPC interceptors.
49
+ GRPC_INTERCEPTORS = []
50
+
51
+ DEFAULT_TIMEOUT = 30
52
+
53
+ # The scopes needed to make gRPC calls to all of the methods defined in
54
+ # this service.
55
+ ALL_SCOPES = [
56
+ ].freeze
57
+
58
+
59
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
60
+ # Provides the means for authenticating requests made by the client. This parameter can
61
+ # be many types.
62
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
63
+ # authenticating requests made by this client.
64
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
65
+ # credentials for this client.
66
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
67
+ # credentials for this client.
68
+ # A `GRPC::Core::Channel` will be used to make calls through.
69
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
70
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
71
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
72
+ # metadata for requests, generally, to give OAuth credentials.
73
+ # @param scopes [Array<String>]
74
+ # The OAuth scopes for this service. This parameter is ignored if
75
+ # an updater_proc is supplied.
76
+ # @param client_config [Hash]
77
+ # A Hash for call options for each method. See
78
+ # Google::Gax#construct_settings for the structure of
79
+ # this data. Falls back to the default config if not specified
80
+ # or the specified config is missing data points.
81
+ # @param timeout [Numeric]
82
+ # The default timeout, in seconds, for calls made through this client.
83
+ # @param metadata [Hash]
84
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
85
+ # @param exception_transformer [Proc]
86
+ # An optional proc that intercepts any exceptions raised during an API call to inject
87
+ # custom error handling.
88
+ def initialize \
89
+ credentials: nil,
90
+ scopes: ALL_SCOPES,
91
+ client_config: {},
92
+ timeout: DEFAULT_TIMEOUT,
93
+ metadata: nil,
94
+ exception_transformer: nil,
95
+ lib_name: nil,
96
+ lib_version: ""
97
+ # These require statements are intentionally placed here to initialize
98
+ # the gRPC module only when it's required.
99
+ # See https://github.com/googleapis/toolkit/issues/446
100
+ require "google/gax/grpc"
101
+ require "google/ads/google_ads/v1/services/conversion_adjustment_upload_service_services_pb"
102
+
103
+ credentials ||= Google::Ads::GoogleAds::V1::Services::Credentials.default
104
+
105
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
106
+ updater_proc = Google::Ads::GoogleAds::V1::Services::Credentials.new(credentials).updater_proc
107
+ end
108
+ if credentials.is_a?(GRPC::Core::Channel)
109
+ channel = credentials
110
+ end
111
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
112
+ chan_creds = credentials
113
+ end
114
+ if credentials.is_a?(Proc)
115
+ updater_proc = credentials
116
+ end
117
+ if credentials.is_a?(Google::Auth::Credentials)
118
+ updater_proc = credentials.updater_proc
119
+ end
120
+
121
+ package_version = Gem.loaded_specs['google-ads-googleads'].version.version
122
+
123
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
124
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
125
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
126
+ google_api_client << " grpc/#{GRPC::VERSION}"
127
+ google_api_client.freeze
128
+
129
+ headers = { :"x-goog-api-client" => google_api_client }
130
+ headers.merge!(metadata) unless metadata.nil?
131
+ client_config_file = Pathname.new(__dir__).join(
132
+ "conversion_adjustment_upload_service_client_config.json"
133
+ )
134
+ defaults = client_config_file.open do |f|
135
+ Google::Gax.construct_settings(
136
+ "google.ads.googleads.v1.services.ConversionAdjustmentUploadService",
137
+ JSON.parse(f.read),
138
+ client_config,
139
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
140
+ timeout,
141
+ errors: Google::Gax::Grpc::API_ERRORS,
142
+ metadata: headers
143
+ )
144
+ end
145
+
146
+ # Allow overriding the service path/port in subclasses.
147
+ service_path = self.class::SERVICE_ADDRESS
148
+ port = self.class::DEFAULT_SERVICE_PORT
149
+ interceptors = self.class::GRPC_INTERCEPTORS
150
+ @conversion_adjustment_upload_service_stub = Google::Gax::Grpc.create_stub(
151
+ service_path,
152
+ port,
153
+ chan_creds: chan_creds,
154
+ channel: channel,
155
+ updater_proc: updater_proc,
156
+ scopes: scopes,
157
+ interceptors: interceptors,
158
+ &Google::Ads::GoogleAds::V1::Services::ConversionAdjustmentUploadService::Stub.method(:new)
159
+ )
160
+
161
+ @upload_conversion_adjustments = Google::Gax.create_api_call(
162
+ @conversion_adjustment_upload_service_stub.method(:upload_conversion_adjustments),
163
+ defaults["upload_conversion_adjustments"],
164
+ exception_transformer: exception_transformer
165
+ )
166
+ end
167
+
168
+ # Service calls
169
+
170
+ # Processes the given conversion adjustments.
171
+ #
172
+ # @param customer_id [String]
173
+ # The ID of the customer performing the upload.
174
+ # @param conversion_adjustments [Array<Google::Ads::GoogleAds::V1::Services::ConversionAdjustment | Hash>]
175
+ # The conversion adjustments that are being uploaded.
176
+ # A hash of the same form as `Google::Ads::GoogleAds::V1::Services::ConversionAdjustment`
177
+ # can also be provided.
178
+ # @param partial_failure [true, false]
179
+ # If true, successful operations will be carried out and invalid
180
+ # operations will return errors. If false, all operations will be carried out
181
+ # in one transaction if and only if they are all valid. This should always be
182
+ # set to true.
183
+ # @param options [Google::Gax::CallOptions]
184
+ # Overrides the default settings for this call, e.g, timeout,
185
+ # retries, etc.
186
+ # @yield [result, operation] Access the result along with the RPC operation
187
+ # @yieldparam result [Google::Ads::GoogleAds::V1::Services::UploadConversionAdjustmentsResponse]
188
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
189
+ # @return [Google::Ads::GoogleAds::V1::Services::UploadConversionAdjustmentsResponse]
190
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
191
+ # @example
192
+ # require "google/ads/google_ads"
193
+ #
194
+ # conversion_adjustment_upload_service_client = Google::Ads::GoogleAds::ConversionAdjustmentUpload.new(version: :v1)
195
+ #
196
+ # # TODO: Initialize `customer_id`:
197
+ # customer_id = ''
198
+ #
199
+ # # TODO: Initialize `conversion_adjustments`:
200
+ # conversion_adjustments = []
201
+ # response = conversion_adjustment_upload_service_client.upload_conversion_adjustments(customer_id, conversion_adjustments)
202
+
203
+ def upload_conversion_adjustments \
204
+ customer_id,
205
+ conversion_adjustments,
206
+ partial_failure: nil,
207
+ options: nil,
208
+ &block
209
+ req = {
210
+ customer_id: customer_id,
211
+ conversion_adjustments: conversion_adjustments,
212
+ partial_failure: partial_failure
213
+ }.delete_if { |_, v| v.nil? }
214
+ req = Google::Gax::to_proto(req, Google::Ads::GoogleAds::V1::Services::UploadConversionAdjustmentsRequest)
215
+ @upload_conversion_adjustments.call(req, options, &block)
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,31 @@
1
+ {
2
+ "interfaces": {
3
+ "google.ads.googleads.v1.services.ConversionAdjustmentUploadService": {
4
+ "retry_codes": {
5
+ "idempotent": [
6
+ "DEADLINE_EXCEEDED",
7
+ "UNAVAILABLE"
8
+ ],
9
+ "non_idempotent": []
10
+ },
11
+ "retry_params": {
12
+ "default": {
13
+ "initial_retry_delay_millis": 100,
14
+ "retry_delay_multiplier": 1.3,
15
+ "max_retry_delay_millis": 60000,
16
+ "initial_rpc_timeout_millis": 20000,
17
+ "rpc_timeout_multiplier": 1.0,
18
+ "max_rpc_timeout_millis": 20000,
19
+ "total_timeout_millis": 600000
20
+ }
21
+ },
22
+ "methods": {
23
+ "UploadConversionAdjustments": {
24
+ "timeout_millis": 60000,
25
+ "retry_codes_name": "non_idempotent",
26
+ "retry_params_name": "default"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }