syntax = "proto3";

package com.wix.media.media_manager.v1;

import "wix/api/validations.proto";
import "wix/api/permissions.proto";
import "wix/api/annotations.proto";
import "google/api/annotations.proto";
import "wix/api/entity.proto";
import "google/protobuf/wrappers.proto";
import "com/wix/media/site_media/v1/file_descriptor.proto";
import "com/wix/media/site_media/upstream/wix/common/paging.proto";
import "com/wix/media/site_media/v1/namespace.proto";
import "com/wix/media/media_manager/v1/item_type.proto";



message ListTrashBinFilesInUseRequest {
  // A list of file IDs to validate in the trash.
  repeated google.protobuf.StringValue file_ids = 1 [(.wix.api.maxSize) = 1000, (.wix.api.maxLength) = 1000];
  // Validates files under the folders in the trash.
  repeated google.protobuf.StringValue folder_ids = 2 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 100];
  // Validated all files under the trash root
  // Note - when set to true, no file ids and parent folder ids are allowed
  // Default - false
  google.protobuf.BoolValue all_content = 3;
  // The number of days to look for file use
  // default 30 days
  // max time is 180 days
  google.protobuf.Int32Value used_in_last_days = 4 [(.wix.api.min) = 1, (.wix.api.max) = 180];
  // Cursor and paging information.
  // Note, cursor will only affect the results from folders or when searching for all files in trash
  // Files return by the id list will always be returned in addition to files in selected folders
  com.wix.media.site_media.upstream.wix.common.CursorPaging paging = 5;
  // The namespace to list from
  // Note - Namespace value `Others` is not supported and will produce an error
  com.wix.media.site_media.v1.Namespace namespace = 6;
}

message ListTrashBinFilesInUseResponse {
  // A List of files that have been used in the selected period
  repeated com.wix.media.site_media.v1.FileDescriptor files = 1 [(.wix.api.maxSize) = 1000];
  // The metadata for the page including the next cursor if one exist
  com.wix.media.site_media.upstream.wix.common.PagingMetadataV2 paging_metadata = 2;
}


message BulkDeleteRequest {
  enum DeleteMode {
    // Delete only unused files according to the `usedInLastDays` - safe delete
    ONLY_UNUSED = 0;
    // Delete all files
    ALL = 1;
  }

  message BulkDeleteOptions{
    // Validated all files under the trash root
    // Note - when set to true, no file ids and parent folder ids are allowed
    // Default - false
    google.protobuf.BoolValue all_trash_content = 1;
    // The number of days to look for file use
    // default 30 days when delete mode is ONLY_UNUSED
    // will return an error if delete mode is ALL
    google.protobuf.Int32Value used_in_last_days = 2;
    // Delete mode
    DeleteMode delete_mode = 3;
    // if the files should be permanently deleted
    // Default - false
    // note - false is not implemented yet
    google.protobuf.BoolValue permanent = 4;

  }
  // A list of file IDs to validate in the trash.
  repeated google.protobuf.StringValue file_ids = 1 [(.wix.api.maxSize) = 1000, (.wix.api.maxLength) = 1000];
  // Validates files under the parent folders in the trash.
  repeated google.protobuf.StringValue folder_ids = 2 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 100];
  // Cursor and paging information.
  // Note, pagingLimit will only affect the results from folders or when searching for all content in trash
  // Files return by the id list will always be returned in addition to files in selected folders
  google.protobuf.Int32Value paging_limit = 3;
  // Options for the delete operation
  BulkDeleteOptions options = 4;
  // The namespace to list from
  // Note - Namespace value `Others` is not supported and will produce an error
  com.wix.media.site_media.v1.Namespace namespace = 5;
}

message BulkDeleteResponse {
  // A List of files that have been used in the selected period
  repeated com.wix.media.site_media.v1.FileDescriptor files = 1 [(.wix.api.maxSize) = 1000];
  // The metadata for the page including the next cursor if one exist
  com.wix.media.site_media.upstream.wix.common.PagingMetadataV2 paging_metadata = 2;
  // The operation id for the delete operation
  google.protobuf.StringValue operation_id = 3 [(.wix.api.maxLength) = 30];
}

message AsyncBulkCopyRequest {
  message CopyDestination {

    // The id of the destination folder
    google.protobuf.StringValue folder_id = 1 [(.wix.api.maxLength) = 100];
    // The namespace to list from
    // The site_id of the destination site
    //    google.protobuf.StringValue site_id = 2 [(.wix.api.maxLength) = 100];
    // Note - Namespace values `OTHERS`/`DRAFTS` is not supported and will produce an error
    //    com.wix.media.site_media.v1.Namespace namespace = 3;
  }

  message CopyItemRequest {
    // the id of the file or folder to copy
    google.protobuf.StringValue item_id = 1  [(.wix.api.maxLength) = 1000];
    // the type of the item to copy
    ItemType type = 2;
    // the name of the item in the destination
    google.protobuf.StringValue copy_name = 3 [(.wix.api.maxLength) = 200];
    // The id of the site containing the file
    // google.protobuf.StringValue site_id =  5;
  }

  message CopySource {
    // A list of items that will be copied.
    repeated CopyItemRequest items = 1 [(.wix.api.maxSize) = 500];
    // The id of the site containing the items
    google.protobuf.StringValue site_id = 2 [(.wix.api.maxLength) = 100];
  }
  // The information about the items to copy
  CopySource source  = 1;
  // The destination of the items to copy
  CopyDestination destination = 2;
  // The namespace for the request - items from other namespaces will be ignored
  // Note - Namespace values `OTHERS`/`DRAFTS` are not supported and will produce an error
  com.wix.media.site_media.v1.Namespace namespace = 3;
}

message AsyncBulkCopyResponse {
}

message BulkMoveRequest {
  message MoveDestination {
    // The folder_id of the destination folder
    google.protobuf.StringValue folder_id = 1 [(.wix.api.maxLength) = 100];
  }

  // The destination to move the items to
  MoveDestination destination = 1;

  // A list of file IDs to be moved
  repeated google.protobuf.StringValue file_ids = 2 [(.wix.api.maxSize) = 500, (.wix.api.maxLength) = 1000];
  // A list of folder IDs to be moved
  repeated google.protobuf.StringValue folder_ids = 3 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 100];

  // The namespace for the request - items from other namespaces will be ignored
  // Note - Namespace values `OTHERS`/`DRAFTS` are not supported and will produce an error
  com.wix.media.site_media.v1.Namespace namespace = 4;
}

message BulkMoveResponse {
}

service MediaManagerService {
  option (.wix.api.service_maturity) = ALPHA;
  option (.wix.api.service_exposure) = INTERNAL;
  option (.wix.api.service_entity).message = "com.wix.media.media_manager.v1.MediaManagerEntity";


  // Use this endpoint to list files that have been used in the selected period that are in the trash
  // Note - when this endpoint is called with file ids the files can be not from the trash bin
  // Note - when this endpoint is called with folder ids, the folders must be folders that are in the trash-bin, folders not in the trash are ignored
  rpc ListTrashBinFilesInUse(ListTrashBinFilesInUseRequest) returns (ListTrashBinFilesInUseResponse) {
    option (google.api.http) = {
      post : "/v1/trash-bin/media-manager/list-used"
    };
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_LIST_USED_FILES";
  }


  // Use this endpoint to list files that have been used in the selected period that are in the trash
  // Note - when this endpoint is called with file ids the files can be not from the trash bin
  // Note - when this endpoint is called with folder ids, the folders must be folders that are in the trash-bin, folders not in the trash are ignored
  rpc BulkDelete (BulkDeleteRequest) returns (BulkDeleteResponse) {
    option (google.api.http) = {
      post : "/v1/bulk/trash-bin/media-manager/delete"
    };
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_PERMANENT_DELETE";
  }


  // Use this endpoint to copy files and folders between sites or on the same site
  // Note - this is an async endpoint and will not return the copied files
  // Note - This is an internal endpoint and does not offer the full async contract - no async job to query
  //  and no indication on the created items that they have been created by this process
  // Note - This endpoint only allows coping items to the same namespace and from the namespace specified in the request
  //  any other items will be ignored
  // Note - copying to and from trash and visitors root folders is not allowed
  // Note - any circular references will be ignored
  rpc AsyncBulkCopy (AsyncBulkCopyRequest) returns (AsyncBulkCopyResponse) {
    option (google.api.http) = {
      post : "/v1/bulk/media-manager/copy"
    };
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_COPY";
  }

  // Use this endpoint to move files and folders on the same site
  // Note - this is an async endpoint and will not return the moved files
  rpc BulkMove (BulkMoveRequest) returns (BulkMoveResponse) {
    option (google.api.http) = {
      post : "/v1/bulk/media-manager/move"
    };
    option (.wix.api.permission).name = "MEDIA.MEDIA_MANAGER_MOVE";
  }

}
