// Copyright 2025 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.admanager.v1;

import "google/ads/admanager/v1/ad_review_center_ad_enums.proto";
import "google/ads/admanager/v1/ad_review_center_ad_messages.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/rpc/status.proto";
import "google/type/interval.proto";

option csharp_namespace = "Google.Ads.AdManager.V1";
option go_package = "google.golang.org/genproto/googleapis/ads/admanager/v1;admanager";
option java_multiple_files = true;
option java_outer_classname = "AdReviewCenterAdServiceProto";
option java_package = "com.google.ads.admanager.v1";
option php_namespace = "Google\\Ads\\AdManager\\V1";
option ruby_package = "Google::Ads::AdManager::V1";

// Provides methods for handling AdReviewCenterAd objects.
service AdReviewCenterAdService {
  option (google.api.default_host) = "admanager.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/admanager";

  // API to search for AdReviewCenterAds.
  rpc SearchAdReviewCenterAds(SearchAdReviewCenterAdsRequest)
      returns (SearchAdReviewCenterAdsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=networks/*/webProperties/*}/adReviewCenterAds:search"
    };
    option (google.api.method_signature) = "parent";
  }

  // API to batch allow AdReviewCenterAds.
  // This method supports partial success. Some operations may succeed while
  // others fail. Callers should check the failedRequests field in the response
  // to determine which operations failed.
  rpc BatchAllowAdReviewCenterAds(BatchAllowAdReviewCenterAdsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=networks/*/webProperties/*}/adReviewCenterAds:batchAllow"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
    option (google.longrunning.operation_info) = {
      response_type: "BatchAllowAdReviewCenterAdsResponse"
      metadata_type: "BatchAdReviewCenterAdsOperationMetadata"
    };
  }

  // API to batch block AdReviewCenterAds.
  // This method supports partial success. Some operations may succeed while
  // others fail. Callers should check the failedRequests field in the response
  // to determine which operations failed.
  rpc BatchBlockAdReviewCenterAds(BatchBlockAdReviewCenterAdsRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=networks/*/webProperties/*}/adReviewCenterAds:batchBlock"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
    option (google.longrunning.operation_info) = {
      response_type: "BatchBlockAdReviewCenterAdsResponse"
      metadata_type: "BatchAdReviewCenterAdsOperationMetadata"
    };
  }
}

// Request object for `SearchAdReviewCenterAds` method.
message SearchAdReviewCenterAdsRequest {
  // Required. The parent, which owns this collection of AdReviewCenterAds.
  // Format: networks/{network_code}/webProperties/{web_property_code}
  //
  // Since a network can only have a single web property of each
  // `ExchangeSyndicationProduct`, you can use the
  // `ExchangeSyndicationProduct` as an alias for the web property code:
  //
  // `networks/{network_code}/webProperties/display`
  //
  // `networks/{network_code}/webProperties/videoAndAudio`
  //
  // `networks/{network_code}/webProperties/mobileApp`
  //
  // `networks/{network_code}/webProperties/games`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/WebProperty"
    }
  ];

  // Optional. The maximum number of AdReviewCenterAds to return. The service
  // may return fewer than this value. If unspecified, at most 50
  // AdReviewCenterAds will be returned. The maximum value is 1000; values
  // greater than 1000 will be coerced to 1000.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The page token to fetch the next page of AdReviewCenterAds. This
  // is the value returned from a previous Search request, or empty.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Only return ads with the given status.
  AdReviewCenterAdStatusEnum.AdReviewCenterAdStatus status = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Only return ads with the given AdReviewCenterAd IDs. If provided,
  // no other filter can be set (other than page size and page token).
  repeated string ad_review_center_ad_id = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If provided, only return ads that served within the given date
  // range (inclusive). The  date range must be within the last 30 days. If not
  // provided, the date range will be the last 30 days.
  google.type.Interval date_time_range = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If provided, restrict the search to AdReviewCenterAds associated
  // with the text (including any text on the ad or in the destination URL). If
  // more than one value is provided, the search will combine them in a logical
  // AND. For example, ['car', 'blue'] will match ads that contain both "car"
  // and "blue", but not an ad that only contains "car".
  repeated string search_text = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. If provided, restrict the search to creatives belonging to one of
  // the given Adx buyer account IDs. Only applicable to RTB creatives. Adx
  // buyer account IDs can be found via the ProgrammaticBuyerService.
  repeated int64 buyer_account_id = 8 [(google.api.field_behavior) = OPTIONAL];
}

// Response object for `SearchAdReviewCenterAds` method.
message SearchAdReviewCenterAdsResponse {
  // The AdReviewCenterAds that match the search request.
  repeated AdReviewCenterAd ad_review_center_ads = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request object for `BatchAllowAdReviewCenterAds` method.
message BatchAllowAdReviewCenterAdsRequest {
  // Required. The parent, which owns this collection of AdReviewCenterAds.
  // Format: networks/{network_code}/webProperties/{web_property_code}
  //
  // Since a network can only have a single web property of each
  // `ExchangeSyndicationProduct`, you can use the
  // `ExchangeSyndicationProduct` as an alias for the web property code:
  //
  // `networks/{network_code}/webProperties/display`
  //
  // `networks/{network_code}/webProperties/videoAndAudio`
  //
  // `networks/{network_code}/webProperties/mobileApp`
  //
  // `networks/{network_code}/webProperties/games`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/WebProperty"
    }
  ];

  // Required. The resource names of the `AdReviewCenterAd`s to allow.
  // Format:
  // `networks/{network_code}/webProperties/{web_property_code}/adReviewCenterAds/{ad_review_center_ad_id}`
  repeated string names = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/AdReviewCenterAd"
    }
  ];
}

// Response object for `BatchAllowAdReviewCenterAds` method.
message BatchAllowAdReviewCenterAdsResponse {}

// Request object for `BatchBlockAdReviewCenterAds` method.
message BatchBlockAdReviewCenterAdsRequest {
  // Required. The parent, which owns this collection of AdReviewCenterAds.
  // Format: networks/{network_code}/webProperties/{web_property_code}
  //
  // Since a network can only have a single web property of each
  // `ExchangeSyndicationProduct`, you can use the
  // `ExchangeSyndicationProduct` as an alias for the web property code:
  //
  // `networks/{network_code}/webProperties/display`
  //
  // `networks/{network_code}/webProperties/videoAndAudio`
  //
  // `networks/{network_code}/webProperties/mobileApp`
  //
  // `networks/{network_code}/webProperties/games`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/WebProperty"
    }
  ];

  // Required. The resource names of the `AdReviewCenterAd`s to block.
  // Format:
  // `networks/{network_code}/webProperties/{web_property_code}/adReviewCenterAds/{ad_review_center_ad_id}`
  repeated string names = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/AdReviewCenterAd"
    }
  ];
}

// Response object for `BatchBlockAdReviewCenterAds` method.
message BatchBlockAdReviewCenterAdsResponse {}

// Metadata object for `BatchAllowAdReviewCenterAds` and
// `BatchBlockAdReviewCenterAds` methods.
message BatchAdReviewCenterAdsOperationMetadata {
  // The status of each failed request, keyed by the index of the corresponding
  // request in the batch request.
  map<int32, google.rpc.Status> failed_requests = 1;
}
