Class: Google::Ads::GoogleAds::V14::Services::GoogleAdsService::Client
- Inherits:
-
Object
- Object
- Google::Ads::GoogleAds::V14::Services::GoogleAdsService::Client
- Includes:
- Paths
- Defined in:
- lib/google/ads/google_ads/v14/services/google_ads_service/client.rb
Overview
Client for the GoogleAdsService service.
Service to fetch data and metrics across resources.
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
- #google_ads_service_stub ⇒ Object readonly
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the GoogleAdsService Client class.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the GoogleAdsService Client instance.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new GoogleAdsService client object.
-
#mutate(request, options = nil) {|response, operation| ... } ⇒ ::Google::Ads::GoogleAds::V14::Services::MutateGoogleAdsResponse
Creates, updates, or removes resources.
-
#search(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Ads::GoogleAds::V14::Services::GoogleAdsRow>
Returns all rows that match the search query.
-
#search_stream(request, options = nil) {|response, operation| ... } ⇒ ::Enumerable<::Google::Ads::GoogleAds::V14::Services::SearchGoogleAdsStreamResponse>
Returns all rows that match the search stream query.
Methods included from Paths
#accessible_bidding_strategy_path, #account_budget_path, #account_budget_proposal_path, #account_link_path, #ad_group_ad_asset_combination_view_path, #ad_group_ad_asset_view_path, #ad_group_ad_label_path, #ad_group_ad_path, #ad_group_asset_path, #ad_group_asset_set_path, #ad_group_audience_view_path, #ad_group_bid_modifier_path, #ad_group_criterion_customizer_path, #ad_group_criterion_label_path, #ad_group_criterion_path, #ad_group_criterion_simulation_path, #ad_group_customizer_path, #ad_group_extension_setting_path, #ad_group_feed_path, #ad_group_label_path, #ad_group_path, #ad_group_simulation_path, #ad_parameter_path, #ad_path, #ad_schedule_view_path, #age_range_view_path, #asset_field_type_view_path, #asset_group_asset_path, #asset_group_listing_group_filter_path, #asset_group_path, #asset_group_product_group_view_path, #asset_group_signal_path, #asset_path, #asset_set_asset_path, #asset_set_path, #asset_set_type_view_path, #audience_path, #batch_job_path, #bidding_data_exclusion_path, #bidding_seasonality_adjustment_path, #bidding_strategy_path, #bidding_strategy_simulation_path, #billing_setup_path, #call_view_path, #campaign_asset_path, #campaign_asset_set_path, #campaign_audience_view_path, #campaign_bid_modifier_path, #campaign_budget_path, #campaign_conversion_goal_path, #campaign_criterion_path, #campaign_customizer_path, #campaign_draft_path, #campaign_extension_setting_path, #campaign_feed_path, #campaign_group_path, #campaign_label_path, #campaign_path, #campaign_search_term_insight_path, #campaign_shared_set_path, #campaign_simulation_path, #carrier_constant_path, #change_event_path, #change_status_path, #click_view_path, #combined_audience_path, #conversion_action_path, #conversion_custom_variable_path, #conversion_goal_campaign_config_path, #conversion_value_rule_path, #conversion_value_rule_set_path, #currency_constant_path, #custom_audience_path, #custom_conversion_goal_path, #custom_interest_path, #customer_asset_path, #customer_asset_set_path, #customer_client_link_path, #customer_client_path, #customer_conversion_goal_path, #customer_customizer_path, #customer_extension_setting_path, #customer_feed_path, #customer_label_path, #customer_manager_link_path, #customer_negative_criterion_path, #customer_path, #customer_search_term_insight_path, #customer_user_access_invitation_path, #customer_user_access_path, #customizer_attribute_path, #detail_placement_view_path, #detailed_demographic_path, #display_keyword_view_path, #distance_view_path, #domain_category_path, #dynamic_search_ads_search_term_view_path, #expanded_landing_page_view_path, #experiment_arm_path, #experiment_path, #extension_feed_item_path, #feed_item_path, #feed_item_set_link_path, #feed_item_set_path, #feed_item_target_path, #feed_mapping_path, #feed_path, #feed_placeholder_view_path, #gender_view_path, #geo_target_constant_path, #geographic_view_path, #group_placement_view_path, #hotel_group_view_path, #hotel_performance_view_path, #hotel_reconciliation_path, #income_range_view_path, #keyword_plan_ad_group_keyword_path, #keyword_plan_ad_group_path, #keyword_plan_campaign_keyword_path, #keyword_plan_campaign_path, #keyword_plan_path, #keyword_theme_constant_path, #keyword_view_path, #label_path, #landing_page_view_path, #language_constant_path, #lead_form_submission_data_path, #life_event_path, #location_view_path, #managed_placement_view_path, #media_file_path, #mobile_app_category_constant_path, #mobile_device_constant_path, #offline_user_data_job_path, #operating_system_version_constant_path, #paid_organic_search_term_view_path, #parental_status_view_path, #payments_account_path, #per_store_view_path, #product_bidding_category_constant_path, #product_group_view_path, #product_link_path, #qualifying_question_path, #recommendation_path, #remarketing_action_path, #search_term_view_path, #shared_criterion_path, #shared_set_path, #shopping_performance_view_path, #smart_campaign_search_term_view_path, #smart_campaign_setting_path, #third_party_app_analytics_link_path, #topic_constant_path, #topic_view_path, #travel_activity_group_view_path, #travel_activity_performance_view_path, #user_interest_path, #user_list_path, #user_location_view_path, #video_path, #webpage_view_path
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new GoogleAdsService client object.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 108 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/ads/google_ads/v14/services/google_ads_service_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @google_ads_service_stub = ::Gapic::ServiceStub.new( ::Google::Ads::GoogleAds::V14::Services::GoogleAdsService::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end |
Instance Attribute Details
#google_ads_service_stub ⇒ Object (readonly)
37 38 39 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 37 def google_ads_service_stub @google_ads_service_stub end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the GoogleAdsService Client class.
See Configuration for a description of the configuration fields.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 57 def self.configure @configure ||= begin default_config = Client::Configuration.new default_config.timeout = 14_400.0 default_config.retry_policy = { initial_delay: 5.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4] } default_config end yield @configure if block_given? @configure end |
Instance Method Details
#configure {|config| ... } ⇒ Client::Configuration
Configure the GoogleAdsService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
See Configuration for a description of the configuration fields.
87 88 89 90 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 87 def configure yield @config if block_given? @config end |
#mutate(request, options = nil) ⇒ ::Google::Ads::GoogleAds::V14::Services::MutateGoogleAdsResponse #mutate(customer_id: nil, mutate_operations: nil, partial_failure: nil, validate_only: nil, response_content_type: nil) ⇒ ::Google::Ads::GoogleAds::V14::Services::MutateGoogleAdsResponse
Creates, updates, or removes resources. This method supports atomic transactions with multiple types of resources. For example, you can atomically create a campaign and a campaign budget, or perform up to thousands of mutates atomically.
This method is essentially a wrapper around a series of mutate methods. The only features it offers over calling those methods directly are:
-
Atomic transactions
-
Temp resource names (described below)
-
Somewhat reduced latency over making a series of mutate calls
Note: Only resources that support atomic transactions are included, so this method can’t replace all calls to individual services.
## Atomic Transaction Benefits
Atomicity makes error handling much easier. If you’re making a series of changes and one fails, it can leave your account in an inconsistent state. With atomicity, you either reach the chosen state directly, or the request fails and you can retry.
## Temp Resource Names
Temp resource names are a special type of resource name used to create a resource and reference that resource in the same request. For example, if a campaign budget is created with ‘resource_name` equal to `customers/123/campaignBudgets/-1`, that resource name can be reused in the `Campaign.budget` field in the same request. That way, the two resources are created and linked atomically.
To create a temp resource name, put a negative number in the part of the name that the server would normally allocate.
Note:
-
Resources must be created with a temp name before the name can be reused. For example, the previous CampaignBudget+Campaign example would fail if the mutate order was reversed.
-
Temp names are not remembered across requests.
-
There’s no limit to the number of temp names in a request.
-
Each temp name must use a unique negative number, even if the resource types differ.
## Latency
It’s important to group mutates by resource type or the request may time out and fail. Latency is roughly equal to a series of calls to individual mutate methods, where each change in resource type is a new call. For example, mutating 10 campaigns then 10 ad groups is like 2 calls, while mutating 1 campaign, 1 ad group, 1 campaign, 1 ad group is like 4 calls.
List of thrown errors:
[AdCustomizerError]()
[AdError]()
[AdGroupAdError]()
[AdGroupCriterionError]()
[AdGroupError]()
[AssetError]()
[AuthenticationError]()
[AuthorizationError]()
[BiddingError]()
[CampaignBudgetError]()
[CampaignCriterionError]()
[CampaignError]()
[CampaignExperimentError]()
[CampaignSharedSetError]()
[CollectionSizeError]()
[ContextError]()
[ConversionActionError]()
[CriterionError]()
[CustomerFeedError]()
[DatabaseError]()
[DateError]()
[DateRangeError]()
[DistinctError]()
[ExtensionFeedItemError]()
[ExtensionSettingError]()
[FeedAttributeReferenceError]()
[FeedError]()
[FeedItemError]()
[FeedItemSetError]()
[FieldError]()
[FieldMaskError]()
[FunctionParsingError]()
[HeaderError]()
[ImageError]()
[InternalError]()
[KeywordPlanAdGroupKeywordError]()
[KeywordPlanCampaignError]()
[KeywordPlanError]()
[LabelError]()
[ListOperationError]()
[MediaUploadError]()
[MutateError]()
[NewResourceCreationError]()
[NullError]()
[OperationAccessDeniedError]()
[PolicyFindingError]()
[PolicyViolationError]()
[QuotaError]()
[RangeError]()
[RequestError]()
[ResourceCountLimitExceededError]()
[SettingError]()
[SharedSetError]()
[SizeLimitError]()
[StringFormatError]()
[StringLengthError]()
[UrlFieldError]()
[UserListError]()
[YoutubeVideoRegistrationError]()
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 548 def mutate request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Ads::GoogleAds::V14::Services::MutateGoogleAdsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.mutate..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Ads::GoogleAds::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.customer_id header_params["customer_id"] = request.customer_id end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.mutate.timeout, metadata: , retry_policy: @config.rpcs.mutate.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @google_ads_service_stub.call_rpc :mutate, request, options: do |response, operation| yield response, operation if block_given? return response end # rescue GRPC::BadStatus => grpc_error # raise Google::Ads::GoogleAds::Error.new grpc_error.message end |
#search(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Ads::GoogleAds::V14::Services::GoogleAdsRow> #search(customer_id: nil, query: nil, page_token: nil, page_size: nil, validate_only: nil, return_total_results_count: nil, summary_row_setting: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Ads::GoogleAds::V14::Services::GoogleAdsRow>
Returns all rows that match the search query.
List of thrown errors:
[AuthenticationError]()
[AuthorizationError]()
[ChangeEventError]()
[ChangeStatusError]()
[ClickViewError]()
[HeaderError]()
[InternalError]()
[QueryError]()
[QuotaError]()
[RequestError]()
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 227 def search request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Ads::GoogleAds::V14::Services::SearchGoogleAdsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.search..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Ads::GoogleAds::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.customer_id header_params["customer_id"] = request.customer_id end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.search.timeout, metadata: , retry_policy: @config.rpcs.search.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @google_ads_service_stub.call_rpc :search, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @google_ads_service_stub, :search, request, response, operation, yield response, operation if block_given? return response end # rescue GRPC::BadStatus => grpc_error # raise Google::Ads::GoogleAds::Error.new grpc_error.message end |
#search_stream(request, options = nil) ⇒ ::Enumerable<::Google::Ads::GoogleAds::V14::Services::SearchGoogleAdsStreamResponse> #search_stream(customer_id: nil, query: nil, summary_row_setting: nil) ⇒ ::Enumerable<::Google::Ads::GoogleAds::V14::Services::SearchGoogleAdsStreamResponse>
Returns all rows that match the search stream query.
List of thrown errors:
[AuthenticationError]()
[AuthorizationError]()
[ChangeEventError]()
[ChangeStatusError]()
[ClickViewError]()
[HeaderError]()
[InternalError]()
[QueryError]()
[QuotaError]()
[RequestError]()
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/google/ads/google_ads/v14/services/google_ads_service/client.rb', line 336 def search_stream request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Ads::GoogleAds::V14::Services::SearchGoogleAdsStreamRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.search_stream..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Ads::GoogleAds::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.customer_id header_params["customer_id"] = request.customer_id end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.search_stream.timeout, metadata: , retry_policy: @config.rpcs.search_stream.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @google_ads_service_stub.call_rpc :search_stream, request, options: do |response, operation| yield response, operation if block_given? return response end # rescue GRPC::BadStatus => grpc_error # raise Google::Ads::GoogleAds::Error.new grpc_error.message end |