// 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.datamanager.v1;

option csharp_namespace = "Google.Ads.DataManager.V1";
option go_package = "cloud.google.com/go/datamanager/apiv1/datamanagerpb;datamanagerpb";
option java_multiple_files = true;
option java_outer_classname = "ProcessingErrorsProto";
option java_package = "com.google.ads.datamanager.v1";
option php_namespace = "Google\\Ads\\DataManager\\V1";
option ruby_package = "Google::Ads::DataManager::V1";

// Error counts for each type of error.
message ErrorInfo {
  // A list of errors and counts per error reason. May not be populated
  // in all cases.
  repeated ErrorCount error_counts = 1;
}

// The error count for a given error reason.
message ErrorCount {
  // The count of records that failed to upload for a given reason.
  int64 record_count = 1;

  // The error reason of the failed records.
  ProcessingErrorReason reason = 2;
}

// Warning counts for each type of warning.
message WarningInfo {
  // A list of warnings and counts per warning reason.
  repeated WarningCount warning_counts = 1;
}

// The warning count for a given warning reason.
message WarningCount {
  // The count of records that have a warning.
  int64 record_count = 1;

  // The warning reason.
  ProcessingWarningReason reason = 2;
}

// The processing error reason.
// New reasons may be added in the future.
enum ProcessingErrorReason {
  // The processing error reason is unknown.
  PROCESSING_ERROR_REASON_UNSPECIFIED = 0;

  // The custom variable is invalid.
  PROCESSING_ERROR_REASON_INVALID_CUSTOM_VARIABLE = 1;

  // The status of the custom variable is not enabled.
  PROCESSING_ERROR_REASON_CUSTOM_VARIABLE_NOT_ENABLED = 2;

  // The conversion is older than max supported age.
  PROCESSING_ERROR_REASON_EVENT_TOO_OLD = 3;

  // The ad user data is denied, either by the user or in
  // the advertiser default settings.
  PROCESSING_ERROR_REASON_DENIED_CONSENT = 4;

  // Advertiser did not give 3P consent for the Ads core platform services.
  PROCESSING_ERROR_REASON_NO_CONSENT = 5;

  // The overall consent (determined from row level consent, request level
  // consent, and account settings) could not be determined for this user
  PROCESSING_ERROR_REASON_UNKNOWN_CONSENT = 6;

  // A conversion with the same GCLID and conversion time already exists in
  // the system.
  PROCESSING_ERROR_REASON_DUPLICATE_GCLID = 7;

  // A conversion with the same order id and conversion action combination was
  // already uploaded.
  PROCESSING_ERROR_REASON_DUPLICATE_TRANSACTION_ID = 8;

  // The gbraid could not be decoded.
  PROCESSING_ERROR_REASON_INVALID_GBRAID = 9;

  // The google click ID could not be decoded.
  PROCESSING_ERROR_REASON_INVALID_GCLID = 10;

  // Merchant id contains non-digit characters.
  PROCESSING_ERROR_REASON_INVALID_MERCHANT_ID = 11;

  // The wbraid could not be decoded.
  PROCESSING_ERROR_REASON_INVALID_WBRAID = 12;

  // Internal error.
  PROCESSING_ERROR_REASON_INTERNAL_ERROR = 13;

  // Enhanced conversions terms are not signed in the destination account.
  PROCESSING_ERROR_REASON_DESTINATION_ACCOUNT_ENHANCED_CONVERSIONS_TERMS_NOT_SIGNED =
      14;

  // The event is invalid.
  PROCESSING_ERROR_REASON_INVALID_EVENT = 15;

  // The matched transactions are less than the minimum threshold.
  PROCESSING_ERROR_REASON_INSUFFICIENT_MATCHED_TRANSACTIONS = 16;

  // The transactions are less than the minimum threshold.
  PROCESSING_ERROR_REASON_INSUFFICIENT_TRANSACTIONS = 17;

  // The event has format error.
  PROCESSING_ERROR_REASON_INVALID_FORMAT = 18;

  // The event has a decryption error.
  PROCESSING_ERROR_REASON_DECRYPTION_ERROR = 19;

  // The DEK failed to be decrypted.
  PROCESSING_ERROR_REASON_DEK_DECRYPTION_ERROR = 20;

  // The WIP is formatted incorrectly or the WIP does not exist.
  PROCESSING_ERROR_REASON_INVALID_WIP = 21;

  // The KEK cannot decrypt data because it is the wrong KEK, or it does not
  // exist.
  PROCESSING_ERROR_REASON_INVALID_KEK = 22;

  // The WIP could not be used because it was rejected by its attestation
  // condition.
  PROCESSING_ERROR_REASON_WIP_AUTH_FAILED = 23;

  // The system did not have the permissions needed to access the KEK.
  PROCESSING_ERROR_REASON_KEK_PERMISSION_DENIED = 24;

  // The system failed to authenticate with AWS.
  PROCESSING_ERROR_REASON_AWS_AUTH_FAILED = 27;

  // Failed to decrypt the
  // [UserIdentifier][google.ads.datamanager.v1.UserIdentifier] data using the
  // DEK.
  PROCESSING_ERROR_REASON_USER_IDENTIFIER_DECRYPTION_ERROR = 25;

  // The user attempted to ingest events with an ad identifier that isn't
  // from the operating account's ads.
  PROCESSING_ERROR_OPERATING_ACCOUNT_MISMATCH_FOR_AD_IDENTIFIER = 26;

  // One-per-click conversion actions cannot be used with BRAIDs.
  PROCESSING_ERROR_REASON_ONE_PER_CLICK_CONVERSION_ACTION_NOT_PERMITTED_WITH_BRAID =
      28;

  // The match ID can not be found.
  PROCESSING_ERROR_REASON_MATCH_ID_NOT_FOUND = 29;

  // The user ID can not be found for the match ID.
  PROCESSING_ERROR_REASON_USER_ID_NOT_FOUND_FOR_MATCH_ID = 30;

  // The user ID can not be found for the GCLID.
  PROCESSING_ERROR_REASON_USER_ID_NOT_FOUND_FOR_GCLID = 31;

  // The user ID can not be found for the DCLID.
  PROCESSING_ERROR_REASON_USER_ID_NOT_FOUND_FOR_DCLID = 32;

  // There are ad identifiers that are invalid.
  PROCESSING_ERROR_REASON_INVALID_AD_IDENTIFIERS = 33;

  // The mobile ID format is invalid.
  PROCESSING_ERROR_REASON_INVALID_MOBILE_ID_FORMAT = 34;

  // The original conversions can't be found.
  PROCESSING_ERROR_REASON_ORIGINAL_CONVERSIONS_NOT_FOUND = 35;

  // The event ID (dclid or impression ID) cannot be decoded.
  PROCESSING_ERROR_REASON_EVENT_ID_DECODE_ERROR = 36;

  // The user ID cannot be found for the given impression ID.
  PROCESSING_ERROR_REASON_USER_ID_NOT_FOUND_FOR_IMPRESSION_ID = 37;

  // The user ID cannot be found.
  PROCESSING_ERROR_REASON_USER_ID_NOT_FOUND = 38;

  // The event timestamp on the event was earlier than the associated click.
  PROCESSING_ERROR_REASON_CONVERSION_PRECEDES_CLICK = 39;

  // The click occurred too recently.
  PROCESSING_ERROR_REASON_TOO_RECENT_CLICK = 40;

  // The event can't be attributed to a click (GCLID). This may be because the
  // click did not come from a Google Ads campaign, for example.
  PROCESSING_ERROR_REASON_INVALID_CLICK = 41;

  // The click from the event isn't associated with the
  // [`operating_account`][google.ads.datamanager.v1.Destination.operating_account]
  // of the destination.
  PROCESSING_ERROR_REASON_INVALID_OPERATING_ACCOUNT_FOR_CLICK = 42;

  // A corresponding click can't be found that matches the provided attributes.
  PROCESSING_ERROR_REASON_CLICK_NOT_FOUND = 43;
}

// The processing warning reason.
enum ProcessingWarningReason {
  // The processing warning reason is unknown.
  PROCESSING_WARNING_REASON_UNSPECIFIED = 0;

  // The system did not have the permissions needed to access the KEK.
  PROCESSING_WARNING_REASON_KEK_PERMISSION_DENIED = 1;

  // The DEK failed to be decrypted.
  PROCESSING_WARNING_REASON_DEK_DECRYPTION_ERROR = 2;

  // The event has a decryption error.
  PROCESSING_WARNING_REASON_DECRYPTION_ERROR = 3;

  // The WIP could not be used because it was rejected by its attestation
  // condition.
  PROCESSING_WARNING_REASON_WIP_AUTH_FAILED = 4;

  // The WIP is formatted incorrectly or the WIP does not exist.
  PROCESSING_WARNING_REASON_INVALID_WIP = 5;

  // The KEK cannot decrypt data because it is the wrong KEK, or it does not
  // exist.
  PROCESSING_WARNING_REASON_INVALID_KEK = 6;

  // Failed to decrypt the
  // [UserIdentifier][google.ads.datamanager.v1.UserIdentifier] data using the
  // DEK.
  PROCESSING_WARNING_REASON_USER_IDENTIFIER_DECRYPTION_ERROR = 7;

  // Internal error.
  PROCESSING_WARNING_REASON_INTERNAL_ERROR = 8;

  // The system failed to authenticate with AWS.
  PROCESSING_WARNING_REASON_AWS_AUTH_FAILED = 9;
}
