// 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;

import "google/ads/datamanager/v1/audience.proto";
import "google/ads/datamanager/v1/consent.proto";
import "google/ads/datamanager/v1/destination.proto";
import "google/ads/datamanager/v1/encryption_info.proto";
import "google/ads/datamanager/v1/event.proto";
import "google/ads/datamanager/v1/request_status_per_destination.proto";
import "google/ads/datamanager/v1/terms_of_service.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";

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 = "IngestionServiceProto";
option java_package = "com.google.ads.datamanager.v1";
option php_namespace = "Google\\Ads\\DataManager\\V1";
option ruby_package = "Google::Ads::DataManager::V1";

// Service for sending audience data to supported destinations.
service IngestionService {
  option (google.api.default_host) = "datamanager.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/datamanager";

  // Uploads a list of
  // [AudienceMember][google.ads.datamanager.v1.AudienceMember] resources to the
  // provided [Destination][google.ads.datamanager.v1.Destination].
  rpc IngestAudienceMembers(IngestAudienceMembersRequest)
      returns (IngestAudienceMembersResponse) {
    option (google.api.http) = {
      post: "/v1/audienceMembers:ingest"
      body: "*"
    };
  }

  // Removes a list of
  // [AudienceMember][google.ads.datamanager.v1.AudienceMember] resources from
  // the provided [Destination][google.ads.datamanager.v1.Destination].
  rpc RemoveAudienceMembers(RemoveAudienceMembersRequest)
      returns (RemoveAudienceMembersResponse) {
    option (google.api.http) = {
      post: "/v1/audienceMembers:remove"
      body: "*"
    };
  }

  // Uploads a list of
  // [Event][google.ads.datamanager.v1.Event] resources from
  // the provided [Destination][google.ads.datamanager.v1.Destination].
  rpc IngestEvents(IngestEventsRequest) returns (IngestEventsResponse) {
    option (google.api.http) = {
      post: "/v1/events:ingest"
      body: "*"
    };
  }

  // Gets the status of a request given request id.
  rpc RetrieveRequestStatus(RetrieveRequestStatusRequest)
      returns (RetrieveRequestStatusResponse) {
    option (google.api.http) = {
      get: "/v1/requestStatus:retrieve"
    };
  }
}

// Request to upload audience members to the provided destinations. Returns an
// [IngestAudienceMembersResponse][google.ads.datamanager.v1.IngestAudienceMembersResponse].
message IngestAudienceMembersRequest {
  // Required. The list of destinations to send the audience members to.
  repeated Destination destinations = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. The list of users to send to the specified destinations. At most
  // 10000 [AudienceMember][google.ads.datamanager.v1.AudienceMember] resources
  // can be sent in a single request.
  repeated AudienceMember audience_members = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. Request-level consent to apply to all users in the request.
  // User-level consent overrides request-level consent, and can be specified in
  // each [AudienceMember][google.ads.datamanager.v1.AudienceMember].
  Consent consent = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. For testing purposes. If `true`, the request is validated but not
  // executed. Only errors are returned, not results.
  bool validate_only = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Required for [UserData][google.ads.datamanager.v1.UserData]
  // uploads. The encoding type of the user identifiers. For hashed user
  // identifiers, this is the encoding type of the hashed string. For encrypted
  // hashed user identifiers, this is the encoding type of the outer encrypted
  // string, but not necessarily the inner hashed string, meaning the inner
  // hashed string could be encoded in a different way than the outer encrypted
  // string. For non `UserData` uploads, this field is ignored.
  Encoding encoding = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Encryption information for
  // [UserData][google.ads.datamanager.v1.UserData] uploads. If not set, it's
  // assumed that uploaded identifying information is hashed but not encrypted.
  // For non `UserData` uploads, this field is ignored.
  EncryptionInfo encryption_info = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The terms of service that the user has accepted/rejected.
  TermsOfService terms_of_service = 7 [(google.api.field_behavior) = OPTIONAL];
}

// Response from the
// [IngestAudienceMembersRequest][google.ads.datamanager.v1.IngestAudienceMembersRequest].
message IngestAudienceMembersResponse {
  // The auto-generated ID of the request.
  string request_id = 1;
}

// Request to remove users from an audience in the provided destinations.
// Returns a
// [RemoveAudienceMembersResponse][google.ads.datamanager.v1.RemoveAudienceMembersResponse].
message RemoveAudienceMembersRequest {
  // Required. The list of destinations to remove the users from.
  repeated Destination destinations = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. The list of users to remove.
  repeated AudienceMember audience_members = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. For testing purposes. If `true`, the request is validated but not
  // executed. Only errors are returned, not results.
  bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Required for [UserData][google.ads.datamanager.v1.UserData]
  // uploads. The encoding type of the user identifiers. Applies to only the
  // outer encoding for encrypted user identifiers. For non `UserData` uploads,
  // this field is ignored.
  Encoding encoding = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Encryption information for
  // [UserData][google.ads.datamanager.v1.UserData] uploads. If not set, it's
  // assumed that uploaded identifying information is hashed but not encrypted.
  // For non `UserData` uploads, this field is ignored.
  EncryptionInfo encryption_info = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response from the
// [RemoveAudienceMembersRequest][google.ads.datamanager.v1.RemoveAudienceMembersRequest].
message RemoveAudienceMembersResponse {
  // The auto-generated ID of the request.
  string request_id = 1;
}

// Request to upload audience members to the provided destinations. Returns an
// [IngestEventsResponse][google.ads.datamanager.v1.IngestEventsResponse].
message IngestEventsRequest {
  // Required. The list of destinations to send the events to.
  repeated Destination destinations = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. The list of events to send to the specified destinations. At most
  // 2000 [Event][google.ads.datamanager.v1.Event] resources
  // can be sent in a single request.
  repeated Event events = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Request-level consent to apply to all users in the request.
  // User-level consent overrides request-level consent, and can be specified in
  // each [Event][google.ads.datamanager.v1.Event].
  Consent consent = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. For testing purposes. If `true`, the request is validated but not
  // executed. Only errors are returned, not results.
  bool validate_only = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Required for [UserData][google.ads.datamanager.v1.UserData]
  // uploads. The encoding type of the user identifiers. For hashed user
  // identifiers, this is the encoding type of the hashed string. For encrypted
  // hashed user identifiers, this is the encoding type of the outer encrypted
  // string, but not necessarily the inner hashed string, meaning the inner
  // hashed string could be encoded in a different way than the outer encrypted
  // string. For non `UserData` uploads, this field is ignored.
  Encoding encoding = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Encryption information for
  // [UserData][google.ads.datamanager.v1.UserData] uploads. If not set, it's
  // assumed that uploaded identifying information is hashed but not encrypted.
  // For non `UserData` uploads, this field is ignored.
  EncryptionInfo encryption_info = 6 [(google.api.field_behavior) = OPTIONAL];
}

// Response from the
// [IngestEventsRequest][google.ads.datamanager.v1.IngestEventsRequest].
message IngestEventsResponse {
  // The auto-generated ID of the request.
  string request_id = 1;
}

// Request to get the status of request made to the DM API for a given request
// ID. Returns a
// [RetrieveRequestStatusResponse][google.ads.datamanager.v1.RetrieveRequestStatusResponse].
message RetrieveRequestStatusRequest {
  // Required. Required. The request ID of the Data Manager API request.
  string request_id = 1 [(google.api.field_behavior) = REQUIRED];
}

// Response from the
// [RetrieveRequestStatusRequest][google.ads.datamanager.v1.RetrieveRequestStatusRequest].
message RetrieveRequestStatusResponse {
  // A list of request statuses per destination. The order of the statuses
  // matches the order of the destinations in the original request.
  repeated RequestStatusPerDestination request_status_per_destination = 1;
}

// The encoding type of the hashed identifying information.
enum Encoding {
  // Unspecified Encoding type. Should never be used.
  ENCODING_UNSPECIFIED = 0;

  // Hex encoding.
  HEX = 1;

  // Base 64 encoding.
  BASE64 = 2;
}
