// 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/enums/ad_network_type.proto";
import "google/ads/googleads/v0/enums/day_of_week.proto";
import "google/ads/googleads/v0/enums/device.proto";
import "google/ads/googleads/v0/enums/hotel_date_selection_type.proto";
import "google/ads/googleads/v0/enums/month_of_year.proto";
import "google/ads/googleads/v0/enums/placeholder_type.proto";
import "google/ads/googleads/v0/enums/search_term_match_type.proto";
import "google/ads/googleads/v0/enums/slot.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/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_group.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/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/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/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_group_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/protobuf/wrappers.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";
// 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;
}

// 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 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 Group referenced in AWQL query.
  google.ads.googleads.v0.resources.CampaignGroup campaign_group = 25;

  // 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 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 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 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;

  // Ad network type.
  google.ads.googleads.v0.enums.AdNetworkTypeEnum.AdNetworkType ad_network_type = 5;

  // Date to which metrics apply.
  // yyyy-MM-dd format, e.g., 2018-04-17.
  google.protobuf.StringValue date = 6;

  // Day of the week, e.g., MONDAY.
  google.ads.googleads.v0.enums.DayOfWeekEnum.DayOfWeek day_of_week = 7;

  // Device to which metrics apply.
  google.ads.googleads.v0.enums.DeviceEnum.Device device = 8;

  // Hotel booking window in days.
  google.protobuf.Int64Value hotel_booking_window_days = 83;

  // Hotel center ID.
  google.protobuf.Int64Value hotel_center_id = 72;

  // Hotel check-in date. Formatted as yyyy-MM-dd.
  google.protobuf.StringValue hotel_check_in_date = 73;

  // Hotel check-in day of week.
  google.ads.googleads.v0.enums.DayOfWeekEnum.DayOfWeek hotel_check_in_day_of_week = 74;

  // Hotel city.
  google.protobuf.StringValue hotel_city = 75;

  // Hotel class.
  google.protobuf.Int32Value hotel_class = 76;

  // Hotel country.
  google.protobuf.StringValue hotel_country = 77;

  // Hotel date selection type.
  google.ads.googleads.v0.enums.HotelDateSelectionTypeEnum.HotelDateSelectionType hotel_date_selection_type = 78;

  // Hotel length of stay.
  google.protobuf.Int32Value hotel_length_of_stay = 79;

  // Hotel state.
  google.protobuf.StringValue hotel_state = 81;

  // Hour of day as a number between 0 and 23, inclusive.
  google.protobuf.Int32Value hour = 9;

  // Month as represented by the date of the first day of a month. Formatted as
  // yyyy-MM-dd.
  google.protobuf.StringValue month = 10;

  // Month of the year, e.g., January.
  google.ads.googleads.v0.enums.MonthOfYearEnum.MonthOfYear month_of_year = 28;

  // Partner hotel ID.
  google.protobuf.StringValue partner_hotel_id = 82;

  // Placeholder type. This is only used with feed item metrics.
  google.ads.googleads.v0.enums.PlaceholderTypeEnum.PlaceholderType placeholder_type = 65;

  // Quarter as represented by the date of the first day of a quarter.
  // Uses the calendar year for quarters, e.g., the second quarter of 2018
  // starts on 2018-04-01. Formatted as yyyy-MM-dd.
  google.protobuf.StringValue quarter = 12;

  // Match type of the keyword that triggered the ad, including variants.
  google.ads.googleads.v0.enums.SearchTermMatchTypeEnum.SearchTermMatchType search_term_match_type = 56;

  // Position of the ad.
  google.ads.googleads.v0.enums.SlotEnum.Slot slot = 13;

  // Week as defined as Monday through Sunday, and represented by the date of
  // Monday. Formatted as yyyy-MM-dd.
  google.protobuf.StringValue week = 14;

  // Year, formatted as yyyy.
  google.protobuf.Int32Value year = 15;
}

// 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;
}

// Response message for [GoogleAdsService.Mutate][google.ads.googleads.v0.services.GoogleAdsService.Mutate].
message MutateGoogleAdsResponse {
  // 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 group mutate operation.
    CampaignGroupOperation campaign_group_operation = 9;

    // 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 group mutate.
    MutateCampaignGroupResult campaign_group_result = 9;

    // 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;
  }
}
