// 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/request_platform_enum.proto";
import "google/ads/admanager/v1/targeted_video_bumper_type_enum.proto";
import "google/ads/admanager/v1/video_position_enum.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.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 = "TargetingProto";
option java_package = "com.google.ads.admanager.v1";
option php_namespace = "Google\\Ads\\AdManager\\V1";
option ruby_package = "Google::Ads::AdManager::V1";

// Targeting expression.
//
message Targeting {
  // Optional. Used to target/exclude various geo targets.
  GeoTargeting geo_targeting = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target various technology targeting dimensions.
  TechnologyTargeting technology_targeting = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target/exclude various ad units and/or placements.
  InventoryTargeting inventory_targeting = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target specific request platforms.
  RequestPlatformTargeting request_platform_targeting = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target key/values, audience segments, and/or CMS
  // metadata.
  CustomTargeting custom_targeting = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target user domains.
  UserDomainTargeting user_domain_targeting = 10
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target video positions.
  VideoPositionTargeting video_position_targeting = 12
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target data segments.
  DataSegmentTargeting data_segment_targeting = 13
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target content.
  ContentTargeting content_targeting = 15
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Used to target mobile applications.
  MobileApplicationTargeting mobile_application_targeting = 18
      [(google.api.field_behavior) = OPTIONAL];
}

// Represents a list of targeted and excluded geos.
message GeoTargeting {
  // Optional. A list of geo resource names that should be targeted/included.
  repeated string targeted_geos = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/GeoTarget"
    }
  ];

  // Optional. A list of geo resource names that should be excluded.
  repeated string excluded_geos = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/GeoTarget"
    }
  ];
}

// Various types of technology targeting expressed by child messages are
// applied with logical AND.
message TechnologyTargeting {
  // Optional. Bandwidth targeting dimension.
  BandwidthTargeting bandwidth_targeting = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Browser targeting dimension.
  BrowserTargeting browser_targeting = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Browser language targeting dimension.
  BrowserLanguageTargeting browser_language_targeting = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Device capability targeting dimension.
  DeviceCapabilityTargeting device_capability_targeting = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Device category targeting dimension.
  DeviceCategoryTargeting device_category_targeting = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Device manufacturer targeting dimension.
  DeviceManufacturerTargeting device_manufacturer_targeting = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Mobile carrier targeting dimension.
  MobileCarrierTargeting mobile_carrier_targeting = 8
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Operating system targeting dimension.
  OperatingSystemTargeting operating_system_targeting = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Bandwidth Targeting.
//
// Reach users accessing the internet via various means of connection, such as
// cable, DSL, or dial-up. Can be useful to target campaigns using
// low-resolution creatives or text ads for users with low bandwidth.
message BandwidthTargeting {
  // Optional. A list of resource names of the bandwidth groups that should be
  // targeted/included.
  repeated string targeted_bandwidth_groups = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/BandwidthGroup"
    }
  ];

  // Optional. A list of resource names of the bandwidth groups that should be
  // excluded.
  repeated string excluded_bandwidth_groups = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/BandwidthGroup"
    }
  ];
}

// Browser Targeting.
//
// Allows publishers to target/exclude a browser type (e.g. Chrome, Firefox,
// Safari). For more information, see
// https://support.google.com/admanager/answer/2884033 (Targeting types >
// Browser).
message BrowserTargeting {
  // Optional. A list of browser resource names that should be
  // targeted/included.
  repeated string targeted_browsers = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Browser"
    }
  ];

  // Optional. A list of browser resource names that should be excluded.
  repeated string excluded_browsers = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Browser"
    }
  ];
}

// Browser Language Targeting.
//
// For ads targeting mobile apps and their associated WebViews, the language
// used is based on the language specified by the user in their mobile device
// settings. If a browser has more than one language assigned to it, each
// language generates an impression.
message BrowserLanguageTargeting {
  // Optional. A list of browser language resource names that should be
  // targeted/included.
  repeated string targeted_browser_languages = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/BrowserLanguage"
    }
  ];

  // Optional. A list of browser language resource names that should be
  // excluded.
  repeated string excluded_browser_languages = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/BrowserLanguage"
    }
  ];
}

// Represents a list of targeted and excluded device categories.
message DeviceCategoryTargeting {
  // Optional. A list of device category resource names that should be
  // targeted/included.
  repeated string targeted_categories = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceCategory"
    }
  ];

  // Optional. A list of device category resource names that should be excluded.
  repeated string excluded_categories = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceCategory"
    }
  ];
}

// Device Capability Targeting.
//
// Can be used to target/exclude users using mobile apps, ad requests resulting
// from apps built on the MRAID standard, or users on devices that are able to
// make phone calls versus devices that aren't able to make phone calls, such as
// tablets.
message DeviceCapabilityTargeting {
  // Optional. A list of device capability resource names that should be
  // targeted/included.
  repeated string targeted_capabilities = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceCapability"
    }
  ];

  // Optional. A list of device capability resource names that should be
  // excluded.
  repeated string excluded_capabilities = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceCapability"
    }
  ];
}

// Device Manufacturer Targeting.
//
// Can be used to target/exclude users on devices made by specific brands or
// companies, such as Apple, Google, Samsung and others. For more information,
// see https://support.google.com/admanager/answer/2884033 ("Targeting types >
// Device manufacturer").
message DeviceManufacturerTargeting {
  // Optional. A list of device manufacturer resource names that should be
  // targeted/included.
  repeated string targeted_device_manufacturers = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceManufacturer"
    }
  ];

  // Optional. A list of device manufacturer resource names that should be
  // excluded.
  repeated string excluded_device_manufacturers = 8 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/DeviceManufacturer"
    }
  ];

  // Optional. A list of mobile device resource names that should be
  // targeted/included.
  repeated string targeted_mobile_devices = 9 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileDevice"
    }
  ];

  // Optional. A list of mobile device resource names that should be excluded.
  repeated string excluded_mobile_devices = 10 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileDevice"
    }
  ];

  // Optional. A list of mobile device submodel resource names that should be
  // targeted/included.
  repeated string targeted_mobile_device_submodels = 11 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileDeviceSubmodel"
    }
  ];

  // Optional. A list of mobile device submodel resource names that should be
  // excluded.
  repeated string excluded_mobile_device_submodels = 12 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileDeviceSubmodel"
    }
  ];
}

// Mobile Carrier Targeting.
//
// Can be used to target/exclude a variety of mobile carriers, such as AT&T,
// Verizon, or T-Mobile.
message MobileCarrierTargeting {
  // Optional. A list of mobile carrier resource names that should be
  // targeted/included.
  repeated string targeted_mobile_carriers = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileCarrier"
    }
  ];

  // Optional. A list of mobile carrier resource names that should be excluded.
  repeated string excluded_mobile_carriers = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/MobileCarrier"
    }
  ];
}

// Operating System Targeting
message OperatingSystemTargeting {
  // Optional. A list of operating system resource names that should be
  // targeted/included.
  repeated string targeted_operating_systems = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/OperatingSystem"
    }
  ];

  // Optional. A list of operating system resource names that should be
  // excluded.
  repeated string excluded_operating_systems = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/OperatingSystem"
    }
  ];

  // Optional. A list of operating system version resource names that should be
  // targeted/included.
  repeated string targeted_operating_system_versions = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/OperatingSystemVersion"
    }
  ];

  // Optional. A list of operating system version resource names that should be
  // excluded.
  repeated string excluded_operating_system_versions = 8 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/OperatingSystemVersion"
    }
  ];
}

// Targeted ad units and AU placements are applied with
// logical OR. Example:
//
//  (au:1 OR au:2 OR au_placement:5) AND (NOT (au:3))
message InventoryTargeting {
  // Optional. A list of ad units that should be targeted/included.
  repeated AdUnitTargeting targeted_ad_units = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. A list of ad units that should be excluded.
  //
  // Excluded AUs take precedence over targeted AUs. In fact an AU can be
  // excluded only if one of its ancestors is targeted. Subsequently child
  // AUs of an excluded AU can not be targeted (except via a placement).
  repeated AdUnitTargeting excluded_ad_units = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The resource names of the placements that should be
  // targeted/included.
  repeated string targeted_placements = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Placement"
    }
  ];
}

// Specifies an ad unit and (optionally) its descendants.
message AdUnitTargeting {
  // Whether this ad unit's children should be targeted/excluded as well.
  optional bool include_descendants = 1;

  // Optional. The resource name of this ad unit.
  optional string ad_unit = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/AdUnit"
    }
  ];
}

// Represents a list of targeted request platforms.
message RequestPlatformTargeting {
  // Optional. The list of request platforms that should be targeted.
  repeated RequestPlatformEnum.RequestPlatform request_platforms = 1
      [(google.api.field_behavior) = OPTIONAL];
}

// Represents the top level targeting expression for custom key/values,
// audience segments, and/or CMS metadata.
message CustomTargeting {
  // Optional. These clauses are all ORed together.
  repeated CustomTargetingClause custom_targeting_clauses = 1
      [(google.api.field_behavior) = OPTIONAL];
}

// Represents a logical AND of individual custom targeting expressions.
message CustomTargetingClause {
  // Optional. Leaf targeting expressions for custom key/values.
  repeated CustomTargetingLiteral custom_targeting_literals = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Leaf targeting expressions for audience segments.
  repeated AudienceSegmentTargeting audience_segment_targetings = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Leaf targeting expressions for cms metadata.
  repeated CmsMetadataTargeting cms_metadata_targetings = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// Represents targeting for custom key/values. The values are ORed together.
message CustomTargetingLiteral {
  // Whether this expression is negatively targeted, meaning it matches
  // ad requests that exclude the below values.
  optional bool negative = 1;

  // Optional. The resource name of the targeted CustomKey.
  optional string custom_targeting_key = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/CustomTargetingKey"
    }
  ];

  // Optional. The resource names of the targeted CustomValues.
  repeated string custom_targeting_values = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/CustomTargetingValue"
    }
  ];
}

// Represents targeting for audience segments. The values are combined in a
// logical `OR`.
message AudienceSegmentTargeting {
  // Whether this expression is negatively targeted, meaning it matches
  // ad requests that exclude the below values.
  optional bool negative = 1;

  // Optional. The targeted audience segments.
  //
  // This is either the resource name of a first-party audience segment or an
  // alias to the effective third-party audience segment. Third-party audience
  // segment resource names containing `~direct` or `~global` will be normalized
  // by the server. For example, `networks/1234/audienceSegments/4567~direct`
  // will be normalized to `networks/1234/audienceSegments/4567`.
  repeated string audience_segments = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/AudienceSegment"
    }
  ];
}

// Represents targeting for CMS metadata. The values are ORed together.
message CmsMetadataTargeting {
  // Whether this expression is negatively targeted, meaning it matches
  // ad requests that exclude the below values.
  optional bool negative = 1;

  // Optional. The resource names of the targeted CMS metadata values.
  repeated string cms_metadata_values = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/CmsMetadataValue"
    }
  ];
}

// User Domain Targeting
message UserDomainTargeting {
  // Optional. A list of user domains that should be targeted/included.
  repeated string targeted_user_domains = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. A list of user domains that should be excluded.
  repeated string excluded_user_domains = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Video Position Targeting
message VideoPositionTargeting {
  // Optional. A list of video position targeting criterion (applied with a
  // logical AND).
  repeated VideoPosition video_positions = 1
      [(google.api.field_behavior) = OPTIONAL];
}

// Video Position Targeting Criterion
message VideoPosition {
  // Optional. The index of the mid-roll to target. This field is ignored when
  // targeting any video position (e.g. position_type) other than MIDROLL.
  optional int64 midroll_index = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The index from the back of the pod of the mid-roll to target.
  // This field is ignored when targeting any video position (e.g.
  // position_type) other than MIDROLL or if targeting a specific midroll index
  // (e.g. midroll_index != 0).
  optional int64 reverse_midroll_index = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The video position within a pod to target. This field must be
  // unset in order to target a specific video position (e.g. position_type),
  // bumper type (e.g. bumper_type), or custom ad spot (e.g. custom_spot_id).
  optional int64 pod_position = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The position within a video to target. A video ad can target a
  // position (pre-roll, all mid-rolls, or post-roll) or a specific mid-roll
  // index.
  optional VideoPositionEnum.VideoPosition position_type = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The video bumper type to target. This field must be unset in
  // order to target a specific video position (e.g. position_type), pod
  // position (e.g. pod_position), or custom ad spot (e.g. custom_spot_id).
  optional TargetedVideoBumperTypeEnum.TargetedVideoBumperType bumper_type = 6
      [(google.api.field_behavior) = OPTIONAL];
}

// Data Segment Targeting
message DataSegmentTargeting {
  // Output only. Whether any data segments are currently targeted.
  bool has_data_segment_targeting = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Content Targeting
//
// Targeted/excluded content entities and bundles.
//
message ContentTargeting {
  // Optional. The resource names of the
  // [Content][google.ads.admanager.v1.Content] that should be
  // targeted/included.
  repeated string targeted_content = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Content"
    }
  ];

  // Optional. The resource names of the
  // [Content][google.ads.admanager.v1.Content] that should be
  // excluded.
  repeated string excluded_content = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Content"
    }
  ];

  // Optional. The resource names of the
  // [ContentBundles][google.ads.admanager.v1.ContentBundle] that
  // should be targeted/included.
  repeated string targeted_content_bundles = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/ContentBundle"
    }
  ];

  // Optional. The resource names of the
  // [ContentBundles][google.ads.admanager.v1.ContentBundle] that
  // should be excluded.
  repeated string excluded_content_bundles = 8 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/ContentBundle"
    }
  ];
}

// Mobile Application Targeting
message MobileApplicationTargeting {
  // The mobile application targeting.
  oneof targeting {
    // Optional. The targeted/excluded first-party mobile applications.
    FirstPartyMobileApplicationTargeting first_party_targeting = 1
        [(google.api.field_behavior) = OPTIONAL];
  }
}

// First-party mobile application targeting.
message FirstPartyMobileApplicationTargeting {
  // Optional. The resource names of the first-party applications that should be
  // targeted.
  repeated string targeted_applications = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Application"
    }
  ];

  // Optional. The resource names of the first-party applications that should be
  // excluded.
  repeated string excluded_applications = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Application"
    }
  ];
}
