// 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/line_item_creative_association_enums.proto";
import "google/ads/admanager/v1/size.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.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 = "LineItemCreativeAssociationMessagesProto";
option java_package = "com.google.ads.admanager.v1";
option php_namespace = "Google\\Ads\\AdManager\\V1";
option ruby_package = "Google::Ads::AdManager::V1";

// A LineItemCreativeAssociation associates a
// [Creative][google.ads.admanager.v1.Creative] or
// [CreativeSet][google.ads.admanager.v1.CreativeSet] with a
// [LineItem][google.ads.admanager.v1.LineItem] so that the creative can be
// served in ad units targeted by the line item.
//
message LineItemCreativeAssociation {
  option (google.api.resource) = {
    type: "admanager.googleapis.com/LineItemCreativeAssociation"
    pattern: "networks/{network_code}/lineItems/{line_item}/creatives/{creative}"
    plural: "lineItemCreativeAssociations"
    singular: "lineItemCreativeAssociation"
  };

  // Identifier. The resource name of the `LineItemCreativeAssociation`.
  // Format:
  // `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Immutable. The [LineItem][google.ads.admanager.v1.LineItem] to
  // which the LineItemCreativeAssociation belongs.
  optional string line_item = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/LineItem"
    }
  ];

  // Optional. Immutable. The [Creative][google.ads.admanager.v1.Creative] to
  // which the LineItemCreativeAssociation associated. Optional if
  // [creativeSet][google.ads.admanager.v1.LineItemCreativeAssociation.creative_set]
  // is set.
  optional string creative = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/Creative"
    }
  ];

  // Optional. Immutable. The [CreativeSet][google.ads.admanager.v1.CreativeSet]
  // to which the LineItemCreativeAssociation associated. Optional if
  // [creative][google.ads.admanager.v1.LineItemCreativeAssociation.creative] is
  // set.
  optional string creative_set = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "admanager.googleapis.com/CreativeSet"
    }
  ];

  // Output only. The status of the association.
  optional
      LineItemCreativeAssociationStatusEnum.LineItemCreativeAssociationStatus
          status = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Overrides the value set for
  // [startTime][google.ads.admanager.v1.LineItem.start_time] of the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item].
  // This value is only valid for Ad Manager 360 networks. If unset, the
  // [startTime][google.ads.admanager.v1.LineItem.start_time] of the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item]
  // will be used.
  optional google.protobuf.Timestamp start_time = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Overrides [endTime][google.ads.admanager.v1.LineItem.end_time] of
  // the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item].
  // This value is only valid for Ad Manager 360 networks. If unset, the
  // [endTime][google.ads.admanager.v1.LineItem.end_time] of the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item]
  // will be used.
  optional google.protobuf.Timestamp end_time = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Overrides the value set for
  // [size][google.ads.admanager.v1.Creative.size] of the
  // [creative][google.ads.admanager.v1.LineItemCreativeAssociation.creative],
  // which allows the creative to be served to ad units that would otherwise not
  // be compatible for its actual size.
  repeated Size sizes = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Overrides the value set for
  // [destinationUrl][Creative.destination_url] of the
  // [creative][google.ads.admanager.v1.LineItemCreativeAssociation.creative].
  // This value is only valid for Ad Manager 360 networks.
  optional string destination_url = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Non-empty default. The weight of the
  // [creative][google.ads.admanager.v1.LineItemCreativeAssociation.creative].
  // This value is only used if the
  // [creativeRotationType][google.ads.admanager.v1.LineItem.creative_rotation_type]
  // of the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item]
  // is set to
  // [WEIGHTED][google.ads.admanager.v1.CreativeRotationTypeEnum.CreativeRotationType.WEIGHTED].
  // Defaults to 10.
  optional double manual_creative_rotation_weight = 10 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = NON_EMPTY_DEFAULT
  ];

  // Optional. Non-empty default. The sequential rotation index of the Creative.
  // This value is used only if the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item]'s
  // [creativeRotationType][google.ads.admanager.v1.LineItem.creative_rotation_type]
  // is set to
  // [SEQUENTIAL][google.ads.admanager.v1.CreativeRotationTypeEnum.CreativeRotationType.SEQUENTIAL].
  // Defaults to 1.
  optional int32 sequential_creative_rotation_index = 11 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = NON_EMPTY_DEFAULT
  ];

  // Optional. Specifies creative targeting for this line item creative
  // association. It should match the
  // [targetingName][CreativePlaceholder.targeting_name] specified on the
  // corresponding [creativePlaceholder][LineItem.creative_placeholder] on the
  // [lineItem][google.ads.admanager.v1.LineItemCreativeAssociation.line_item].
  string targeting_display_name = 12 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The date and time this association was last modified.
  optional google.protobuf.Timestamp update_time = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Contains trafficking statistics for the association.
  optional LineItemCreativeAssociationStats stats = 25
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Contains statistics such as impressions, clicks delivered, and viewable
// impressions for a
// [LineItemCreativeAssociation][google.ads.admanager.v1.LineItemCreativeAssociation].
message LineItemCreativeAssociationStats {
  // Contains statistics such as impressions, clicks delivered, and viewable
  // impressions for creatives belonging to a
  // [CreativeSet][google.ads.admanager.v1.CreativeSet].
  message CreativeStats {
    // Output only. The number of impressions delivered.
    optional int64 impressions_delivered = 1
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The number of clicks delivered.
    optional int64 clicks_delivered = 2
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The number of video completions delivered.
    optional int64 viewable_impressions_delivered = 3
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. The number of impressions delivered.
  optional int64 impressions_delivered = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The number of clicks delivered.
  optional int64 clicks_delivered = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The number of viewable impressions delivered.
  optional int64 viewable_impressions_delivered = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Creative set stats.
  map<int64, CreativeStats> creative_set_stats = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];
}
