syntax = "proto3";

package wix.personalize.optimization_test.v1.upstream.wix.common;

import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/api/errors.proto";

option java_multiple_files = true;
option java_package = "com.wix.personalize.optimization.test.v1.upstream.wix.common";

message BulkActionMetadata {
  option (.wix.api.decomposite_of) = "wix.common.BulkActionMetadata";
  // Number of items that were successfully processed.
  int32 total_successes = 1;
  // Number of items that couldn't be processed.
  int32 total_failures = 2;
  // Number of failures without details because detailed failure threshold was exceeded.
  int32 undetailed_failures = 3;
}

message ItemMetadata {
  option (.wix.api.decomposite_of) = "wix.common.ItemMetadata";
  // Item ID. Should always be available, unless it's impossible (for example, when failing to create an item).
  google.protobuf.StringValue id = 1 [(.wix.api.format) = GUID];
  // Index of the item within the request array. Allows for correlation between request and response items.
  int32 original_index = 2;
  // Whether the requested action was successful for this item. When `false`, the `error` field is populated.
  bool success = 3;
  // Details about the error in case of failure.
  .wix.api.ApplicationError error = 4;
}

enum BulkActionType {
  UNKNOWN_ACTION_TYPE = 0;
  INSERT = 1;
  UPDATE = 2;
  DELETE = 3;
}

/*

Example for using it in your service:

message BulkOrderResult {
    ItemMetadata item_metadata = 1;
    Order item = 2;
}

message BulkArchiveOrdersResponse {
    repeated BulkOrderResult results = 1;
    BulkActionMetadata bulk_action_metadata = 2;
}

*/
