// Copyright 2018 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

package google.ads.googleads.v0.services;

import "google/ads/googleads/v0/common/metrics.proto";
import "google/ads/googleads/v0/common/segments.proto";
import "google/ads/googleads/v0/resources/account_budget.proto";
import "google/ads/googleads/v0/resources/account_budget_proposal.proto";
import "google/ads/googleads/v0/resources/ad_group.proto";
import "google/ads/googleads/v0/resources/ad_group_ad.proto";
import "google/ads/googleads/v0/resources/ad_group_audience_view.proto";
import "google/ads/googleads/v0/resources/ad_group_bid_modifier.proto";
import "google/ads/googleads/v0/resources/ad_group_criterion.proto";
import "google/ads/googleads/v0/resources/ad_group_feed.proto";
import "google/ads/googleads/v0/resources/ad_schedule_view.proto";
import "google/ads/googleads/v0/resources/age_range_view.proto";
import "google/ads/googleads/v0/resources/bidding_strategy.proto";
import "google/ads/googleads/v0/resources/billing_setup.proto";
import "google/ads/googleads/v0/resources/campaign.proto";
import "google/ads/googleads/v0/resources/campaign_audience_view.proto";
import "google/ads/googleads/v0/resources/campaign_bid_modifier.proto";
import "google/ads/googleads/v0/resources/campaign_budget.proto";
import "google/ads/googleads/v0/resources/campaign_criterion.proto";
import "google/ads/googleads/v0/resources/campaign_feed.proto";
import "google/ads/googleads/v0/resources/campaign_shared_set.proto";
import "google/ads/googleads/v0/resources/carrier_constant.proto";
import "google/ads/googleads/v0/resources/change_status.proto";
import "google/ads/googleads/v0/resources/conversion_action.proto";
import "google/ads/googleads/v0/resources/customer.proto";
import "google/ads/googleads/v0/resources/customer_client.proto";
import "google/ads/googleads/v0/resources/customer_client_link.proto";
import "google/ads/googleads/v0/resources/customer_feed.proto";
import "google/ads/googleads/v0/resources/customer_manager_link.proto";
import "google/ads/googleads/v0/resources/display_keyword_view.proto";
import "google/ads/googleads/v0/resources/feed.proto";
import "google/ads/googleads/v0/resources/feed_item.proto";
import "google/ads/googleads/v0/resources/feed_mapping.proto";
import "google/ads/googleads/v0/resources/gender_view.proto";
import "google/ads/googleads/v0/resources/geo_target_constant.proto";
import "google/ads/googleads/v0/resources/hotel_group_view.proto";
import "google/ads/googleads/v0/resources/hotel_performance_view.proto";
import "google/ads/googleads/v0/resources/keyword_plan.proto";
import "google/ads/googleads/v0/resources/keyword_plan_ad_group.proto";
import "google/ads/googleads/v0/resources/keyword_plan_campaign.proto";
import "google/ads/googleads/v0/resources/keyword_plan_keyword.proto";
import "google/ads/googleads/v0/resources/keyword_plan_negative_keyword.proto";
import "google/ads/googleads/v0/resources/keyword_view.proto";
import "google/ads/googleads/v0/resources/language_constant.proto";
import "google/ads/googleads/v0/resources/managed_placement_view.proto";
import "google/ads/googleads/v0/resources/media_file.proto";
import "google/ads/googleads/v0/resources/mobile_app_category_constant.proto";
import "google/ads/googleads/v0/resources/mobile_device_constant.proto";
import "google/ads/googleads/v0/resources/operating_system_version_constant.proto";
import "google/ads/googleads/v0/resources/parental_status_view.proto";
import "google/ads/googleads/v0/resources/product_group_view.proto";
import "google/ads/googleads/v0/resources/recommendation.proto";
import "google/ads/googleads/v0/resources/remarketing_action.proto";
import "google/ads/googleads/v0/resources/search_term_view.proto";
import "google/ads/googleads/v0/resources/shared_criterion.proto";
import "google/ads/googleads/v0/resources/shared_set.proto";
import "google/ads/googleads/v0/resources/topic_constant.proto";
import "google/ads/googleads/v0/resources/topic_view.proto";
import "google/ads/googleads/v0/resources/user_interest.proto";
import "google/ads/googleads/v0/resources/user_list.proto";
import "google/ads/googleads/v0/resources/video.proto";
import "google/ads/googleads/v0/services/ad_group_ad_service.proto";
import "google/ads/googleads/v0/services/ad_group_bid_modifier_service.proto";
import "google/ads/googleads/v0/services/ad_group_criterion_service.proto";
import "google/ads/googleads/v0/services/ad_group_service.proto";
import "google/ads/googleads/v0/services/bidding_strategy_service.proto";
import "google/ads/googleads/v0/services/campaign_bid_modifier_service.proto";
import "google/ads/googleads/v0/services/campaign_budget_service.proto";
import "google/ads/googleads/v0/services/campaign_criterion_service.proto";
import "google/ads/googleads/v0/services/campaign_service.proto";
import "google/ads/googleads/v0/services/campaign_shared_set_service.proto";
import "google/ads/googleads/v0/services/conversion_action_service.proto";
import "google/ads/googleads/v0/services/shared_criterion_service.proto";
import "google/ads/googleads/v0/services/shared_set_service.proto";
import "google/ads/googleads/v0/services/user_list_service.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "google/rpc/status.proto";

option csharp_namespace = "Google.Ads.GoogleAds.V0.Services";
option go_package = "google.golang.org/genproto/googleapis/ads/googleads/v0/services;services";
option java_multiple_files = true;
option java_outer_classname = "GoogleAdsServiceProto";
option java_package = "com.google.ads.googleads.v0.services";
option objc_class_prefix = "GAA";
option php_namespace = "Google\\Ads\\GoogleAds\\V0\\Services";
option ruby_package = "Google::Ads::GoogleAds::V0::Services";
// Proto file describing the GoogleAdsService.

// Service to fetch data and metrics across resources.
service GoogleAdsService {
  // Returns all rows that match the search query.
  rpc Search(SearchGoogleAdsRequest) returns (SearchGoogleAdsResponse) {
    option (google.api.http) = {
      post: "/v0/customers/{customer_id=*}/googleAds:search"
      body: "*"
    };
  }

  // Creates, updates, or removes resources. Operation statuses are returned.
  rpc Mutate(MutateGoogleAdsRequest) returns (MutateGoogleAdsResponse) {
    option (google.api.http) = {
      post: "/v0/customers/{customer_id=*}/googleAds:mutate"
      body: "*"
    };
  }
}

// Request message for [GoogleAdsService.Search][google.ads.googleads.v0.services.GoogleAdsService.Search].
message SearchGoogleAdsRequest {
  // The ID of the customer being queried.
  string customer_id = 1;

  // The query string.
  string query = 2;

  // Token of the page to retrieve. If not specified, the first
  // page of results will be returned. Use the value obtained from
  // `next_page_token` in the previous response in order to request
  // the next page of results.
  string page_token = 3;

  // Number of elements to retrieve in a single page.
  // When too large a page is requested, the server may decide to
  // further limit the number of returned resources.
  int32 page_size = 4;

  // If true, the request is validated but not executed.
  bool validate_only = 5;
}

// Response message for [GoogleAdsService.Search][google.ads.googleads.v0.services.GoogleAdsService.Search].
message SearchGoogleAdsResponse {
  // The list of rows that matched the query.
  repeated GoogleAdsRow results = 1;

  // Pagination token used to retrieve the next page of results.
  // Pass the content of this string as the `page_token` attribute of
  // the next request. `next_page_token` is not returned for the last
  // page.
  string next_page_token = 2;

  // Total number of results that match the query ignoring the LIMIT
  // clause.
  int64 total_results_count = 3;

  // FieldMask that represents what fields were requested by the user.
  google.protobuf.FieldMask field_mask = 5;
}

// A returned row from the query.
message GoogleAdsRow {
  // The account budget in the query.
  google.ads.googleads.v0.resources.AccountBudget account_budget = 42;

  // The account budget proposal referenced in the query.
  google.ads.googleads.v0.resources.AccountBudgetProposal account_budget_proposal = 43;

  // The ad group referenced in the query.
  google.ads.googleads.v0.resources.AdGroup ad_group = 3;

  // The ad referenced in the query.
  google.ads.googleads.v0.resources.AdGroupAd ad_group_ad = 16;

  // The ad group audience view referenced in the query.
  google.ads.googleads.v0.resources.AdGroupAudienceView ad_group_audience_view = 57;

  // The bid modifier referenced in the query.
  google.ads.googleads.v0.resources.AdGroupBidModifier ad_group_bid_modifier = 24;

  // The criterion referenced in the query.
  google.ads.googleads.v0.resources.AdGroupCriterion ad_group_criterion = 17;

  // The ad group feed referenced in the query.
  google.ads.googleads.v0.resources.AdGroupFeed ad_group_feed = 67;

  // The age range view referenced in the query.
  google.ads.googleads.v0.resources.AgeRangeView age_range_view = 48;

  // The ad schedule view referenced in the query.
  google.ads.googleads.v0.resources.AdScheduleView ad_schedule_view = 89;

  // The bidding strategy referenced in the query.
  google.ads.googleads.v0.resources.BiddingStrategy bidding_strategy = 18;

  // The billing setup referenced in the query.
  google.ads.googleads.v0.resources.BillingSetup billing_setup = 41;

  // The campaign budget referenced in the query.
  google.ads.googleads.v0.resources.CampaignBudget campaign_budget = 19;

  // The campaign referenced in the query.
  google.ads.googleads.v0.resources.Campaign campaign = 2;

  // The campaign audience view referenced in the query.
  google.ads.googleads.v0.resources.CampaignAudienceView campaign_audience_view = 69;

  // The campaign bid modifier referenced in the query.
  google.ads.googleads.v0.resources.CampaignBidModifier campaign_bid_modifier = 26;

  // The campaign criterion referenced in the query.
  google.ads.googleads.v0.resources.CampaignCriterion campaign_criterion = 20;

  // The campaign feed referenced in the query.
  google.ads.googleads.v0.resources.CampaignFeed campaign_feed = 63;

  // Campaign Shared Set referenced in AWQL query.
  google.ads.googleads.v0.resources.CampaignSharedSet campaign_shared_set = 30;

  // The carrier constant referenced in the query.
  google.ads.googleads.v0.resources.CarrierConstant carrier_constant = 66;

  // The ChangeStatus referenced in the query.
  google.ads.googleads.v0.resources.ChangeStatus change_status = 37;

  // The conversion action referenced in the query.
  google.ads.googleads.v0.resources.ConversionAction conversion_action = 103;

  // The customer referenced in the query.
  google.ads.googleads.v0.resources.Customer customer = 1;

  // The CustomerManagerLink referenced in the query.
  google.ads.googleads.v0.resources.CustomerManagerLink customer_manager_link = 61;

  // The CustomerClientLink referenced in the query.
  google.ads.googleads.v0.resources.CustomerClientLink customer_client_link = 62;

  // The CustomerClient referenced in the query.
  google.ads.googleads.v0.resources.CustomerClient customer_client = 70;

  // The customer feed referenced in the query.
  google.ads.googleads.v0.resources.CustomerFeed customer_feed = 64;

  // The display keyword view referenced in the query.
  google.ads.googleads.v0.resources.DisplayKeywordView display_keyword_view = 47;

  // The feed referenced in the query.
  google.ads.googleads.v0.resources.Feed feed = 46;

  // The feed item referenced in the query.
  google.ads.googleads.v0.resources.FeedItem feed_item = 50;

  // The feed mapping referenced in the query.
  google.ads.googleads.v0.resources.FeedMapping feed_mapping = 58;

  // The gender view referenced in the query.
  google.ads.googleads.v0.resources.GenderView gender_view = 40;

  // The geo target constant referenced in the query.
  google.ads.googleads.v0.resources.GeoTargetConstant geo_target_constant = 23;

  // The hotel group view referenced in the query.
  google.ads.googleads.v0.resources.HotelGroupView hotel_group_view = 51;

  // The hotel performance view referenced in the query.
  google.ads.googleads.v0.resources.HotelPerformanceView hotel_performance_view = 71;

  // The keyword view referenced in the query.
  google.ads.googleads.v0.resources.KeywordView keyword_view = 21;

  // The keyword plan referenced in the query.
  google.ads.googleads.v0.resources.KeywordPlan keyword_plan = 32;

  // The keyword plan campaign referenced in the query.
  google.ads.googleads.v0.resources.KeywordPlanCampaign keyword_plan_campaign = 33;

  // The keyword plan negative keyword referenced in the query.
  google.ads.googleads.v0.resources.KeywordPlanNegativeKeyword keyword_plan_negative_keyword = 34;

  // The keyword plan ad group referenced in the query.
  google.ads.googleads.v0.resources.KeywordPlanAdGroup keyword_plan_ad_group = 35;

  // The keyword plan keyword referenced in the query.
  google.ads.googleads.v0.resources.KeywordPlanKeyword keyword_plan_keyword = 36;

  // The language constant referenced in the query.
  google.ads.googleads.v0.resources.LanguageConstant language_constant = 55;

  // The managed placement view referenced in the query.
  google.ads.googleads.v0.resources.ManagedPlacementView managed_placement_view = 53;

  // The media file referenced in the query.
  google.ads.googleads.v0.resources.MediaFile media_file = 90;

  // The mobile app category constant referenced in the query.
  google.ads.googleads.v0.resources.MobileAppCategoryConstant mobile_app_category_constant = 87;

  // The mobile device constant referenced in the query.
  google.ads.googleads.v0.resources.MobileDeviceConstant mobile_device_constant = 98;

  // The operating system version constant referenced in the query.
  google.ads.googleads.v0.resources.OperatingSystemVersionConstant operating_system_version_constant = 86;

  // The parental status view referenced in the query.
  google.ads.googleads.v0.resources.ParentalStatusView parental_status_view = 45;

  // The product group view referenced in the query.
  google.ads.googleads.v0.resources.ProductGroupView product_group_view = 54;

  // The recommendation referenced in the query.
  google.ads.googleads.v0.resources.Recommendation recommendation = 22;

  // The search term view referenced in the query.
  google.ads.googleads.v0.resources.SearchTermView search_term_view = 68;

  // The shared set referenced in the query.
  google.ads.googleads.v0.resources.SharedCriterion shared_criterion = 29;

  // The shared set referenced in the query.
  google.ads.googleads.v0.resources.SharedSet shared_set = 27;

  // The topic view referenced in the query.
  google.ads.googleads.v0.resources.TopicView topic_view = 44;

  // The user interest referenced in the query.
  google.ads.googleads.v0.resources.UserInterest user_interest = 59;

  // The user list referenced in the query.
  google.ads.googleads.v0.resources.UserList user_list = 38;

  // The remarketing action referenced in the query.
  google.ads.googleads.v0.resources.RemarketingAction remarketing_action = 60;

  // The topic constant referenced in the query.
  google.ads.googleads.v0.resources.TopicConstant topic_constant = 31;

  // The video referenced in the query.
  google.ads.googleads.v0.resources.Video video = 39;

  // The metrics.
  google.ads.googleads.v0.common.Metrics metrics = 4;

  // The segments.
  google.ads.googleads.v0.common.Segments segments = 102;
}

// Request message for [GoogleAdsService.Mutate][google.ads.googleads.v0.services.GoogleAdsService.Mutate].
message MutateGoogleAdsRequest {
  // The ID of the customer whose resources are being modified.
  string customer_id = 1;

  // The list of operations to perform on individual resources.
  repeated MutateOperation mutate_operations = 2;

  // If true, successful operations will be carried out and invalid
  // operations will return errors. If false, all operations will be carried
  // out in one transaction if and only if they are all valid.
  // Default is false.
  bool partial_failure = 3;

  // If true, the request is validated but not executed. Only errors are
  // returned, not results.
  bool validate_only = 4;
}

// Response message for [GoogleAdsService.Mutate][google.ads.googleads.v0.services.GoogleAdsService.Mutate].
message MutateGoogleAdsResponse {
  // Errors that pertain to operation failures in the partial failure mode.
  // Returned only when partial_failure = true and all errors occur inside the
  // operations. If any errors occur outside the operations (e.g. auth errors),
  // we return an RPC level error.
  google.rpc.Status partial_failure_error = 3;

  // All responses for the mutate.
  repeated MutateOperationResponse mutate_operation_responses = 1;
}

// A single operation (create, update, remove) on a resource.
message MutateOperation {
  // The mutate operation.
  oneof operation {
    // An ad group ad mutate operation.
    AdGroupAdOperation ad_group_ad_operation = 1;

    // An ad group bid modifier mutate operation.
    AdGroupBidModifierOperation ad_group_bid_modifier_operation = 2;

    // An ad group criterion mutate operation.
    AdGroupCriterionOperation ad_group_criterion_operation = 3;

    // An ad group mutate operation.
    AdGroupOperation ad_group_operation = 5;

    // A bidding strategy mutate operation.
    BiddingStrategyOperation bidding_strategy_operation = 6;

    // A campaign bid modifier mutate operation.
    CampaignBidModifierOperation campaign_bid_modifier_operation = 7;

    // A campaign budget mutate operation.
    CampaignBudgetOperation campaign_budget_operation = 8;

    // A campaign mutate operation.
    CampaignOperation campaign_operation = 10;

    // A campaign shared set mutate operation.
    CampaignSharedSetOperation campaign_shared_set_operation = 11;

    // A conversion action mutate operation.
    ConversionActionOperation conversion_action_operation = 12;

    // A campaign criterion mutate operation.
    CampaignCriterionOperation campaign_criterion_operation = 13;

    // A shared criterion mutate operation.
    SharedCriterionOperation shared_criterion_operation = 14;

    // A shared set mutate operation.
    SharedSetOperation shared_set_operation = 15;

    // A user list mutate operation.
    UserListOperation user_list_operation = 16;
  }
}

// Response message for the resource mutate.
message MutateOperationResponse {
  // The mutate response
  oneof response {
    // The result for the ad group ad mutate.
    MutateAdGroupAdResult ad_group_ad_result = 1;

    // The result for the ad group bid modifier mutate.
    MutateAdGroupBidModifierResult ad_group_bid_modifier_result = 2;

    // The result for the ad group criterion mutate.
    MutateAdGroupCriterionResult ad_group_criterion_result = 3;

    // The result for the ad group mutate.
    MutateAdGroupResult ad_group_result = 5;

    // The result for the bidding strategy mutate.
    MutateBiddingStrategyResult bidding_strategy_result = 6;

    // The result for the campaign bid modifier mutate.
    MutateCampaignBidModifierResult campaign_bid_modifier_result = 7;

    // The result for the campaign budget mutate.
    MutateCampaignBudgetResult campaign_budget_result = 8;

    // The result for the campaign mutate.
    MutateCampaignResult campaign_result = 10;

    // The result for the campaign shared set mutate.
    MutateCampaignSharedSetResult campaign_shared_set_result = 11;

    // The result for the conversion action mutate.
    MutateConversionActionResult conversion_action_result = 12;

    // The result for the campaign criterion mutate.
    MutateCampaignCriterionResult campaign_criterion_result = 13;

    // The result for the shared criterion mutate.
    MutateSharedCriterionResult shared_criterion_result = 14;

    // The result for the shared set mutate.
    MutateSharedSetResult shared_set_result = 15;

    // The result for the user list mutate.
    MutateUserListResult user_list_result = 16;
  }
}
