// Copyright 2026 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_break_optimization_type_enum.proto";
import "google/ads/admanager/v1/ad_rule_fill_order_direction_enum.proto";
import "google/ads/admanager/v1/ad_spot_fill_type_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 = "BreakTemplateMessagesProto";
option java_package = "com.google.ads.admanager.v1";
option php_namespace = "Google\\Ads\\AdManager\\V1";
option ruby_package = "Google::Ads::AdManager::V1";

// A `BreakTemplate` defines what kinds of ads show at which positions within a
// pod. Break templates are made up of `AdSpot` objects. A break template must
// have a single ad spot that has `flexible` set to `true`.
message BreakTemplate {
  option (google.api.resource) = {
    type: "admanager.googleapis.com/BreakTemplate"
    pattern: "networks/{network_code}/breakTemplates/{break_template}"
    plural: "breakTemplates"
    singular: "breakTemplate"
  };

  // Identifier. The resource name of the `BreakTemplate`.
  // Format: `networks/{network_code}/breakTemplates/{break_template_id}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. Whether this is a custom template. Custom templates get created
  // outside of the ad rule workflow and can be referenced in ad tags. Only
  // custom templates can have names and display names.
  optional bool custom_template = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Name of the `BreakTemplate`. The name is case insensitive and can
  // be referenced in ad tags. This value is required if `customTemplate` is
  // true, and cannot be set otherwise. You can use alphanumeric characters and
  // symbols other than the following: ", ', =, !, +, #, ,, ~, ;, ^, (, ), <, >,
  // [, ], the white space character.
  optional string ad_tag_name = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Descriptive name for the BreakTemplate. This value is optional if
  // customTemplate is true, and cannot be set otherwise.
  optional string display_name = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The list of the `BreakTemplateMember` objects in the order in
  // which they should appear in the ad pod. Each `BreakTemplateMember` has a
  // reference to an `AdSpot`, which defines what kinds of ads can appear at
  // that position, as well as other metadata that defines how each ad spot
  // should be filled.
  repeated BreakTemplateMember break_template_members = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The optimization type of the pod. This field is optional and
  // defaults to
  // [AdBreakOptimizationTypeEnum.AdBreakOptimizationType.REVENUE][google.ads.admanager.v1.AdBreakOptimizationTypeEnum.AdBreakOptimizationType.REVENUE].
  optional AdBreakOptimizationTypeEnum.AdBreakOptimizationType
      ad_break_optimization_type = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The fill order direction of the pod. This value is required if
  // [adBreakOptimizationType][google.ads.admanager.v1.BreakTemplate.ad_break_optimization_type]
  // is equal to
  // [AdBreakOptimizationTypeEnum.AdBreakOptimizationType.POSITION][google.ads.admanager.v1.AdBreakOptimizationTypeEnum.AdBreakOptimizationType.POSITION]
  // and should otherwise be unset.
  optional AdRuleFillOrderDirectionEnum.AdRuleFillOrderDirection
      fill_order_direction_type = 7 [(google.api.field_behavior) = OPTIONAL];
}

// A building block of a pod template.
message BreakTemplateMember {
  // Required. The ID of the `AdSpot` that has the settings about what kinds of
  // ads can appear in this position of the `BreakTemplate`.
  optional string ad_spot = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/AdSpot"
    }
  ];

  // Optional. The behavior for how the `AdSpot` should be filled in the context
  // of the `BreakTemplate`.
  optional AdSpotFillTypeEnum.AdSpotFillType ad_spot_fill_type = 2
      [(google.api.field_behavior) = OPTIONAL];
}
