syntax = "proto3";

package com.wix.media.site_media.v1;

import "wix/api/validations.proto";
import "wix/api/permissions.proto";
import "wix/api/annotations.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/wrappers.proto";
import "com/wix/media/site_media/v1/file_descriptor.proto";
import "com/wix/media/site_media/v1/download_url.proto";
import "com/wix/media/site_media/v1/media_type.proto";
import "com/wix/media/site_media/v1/image_annotation_type.proto";
import "com/wix/media/site_media/v1/namespace.proto";
import "com/wix/media/site_media/v1/upload_protocol.proto";
import "com/wix/media/site_media/v1/root_folders.proto";
import "com/wix/media/site_media/v1/content_disposition.proto";
import "wix/api/entity.proto";
import "com/wix/media/site_media/upstream/wix/common/paging.proto";
import "wix/api/callback.proto";
import "wix/common/sorting.proto";
import "wix/api/api_errors.proto";
import "google/protobuf/struct.proto";
import "wix/http/field_mask.proto";
import "wix/common/bulk.proto";
import "wix/sdk/definitions.proto";
import "wix/api/errors.proto";
import "wix/api/action_payload.proto";


message GenerateFilesDownloadUrlRequest {
  // IDs of the files to download.
  //
  // You can also specify the files' Wix media URLs. For example, `["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  repeated string file_ids = 1 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 1000, (.wix.api.maxLength) = 1000];
}

message GenerateFilesDownloadUrlResponse {
  // URL for downloading the compressed file containing the specified files in the Media Manager. 
  string download_url = 1 [(.wix.api.format) = WEB_URL];
}

message GenerateFileDownloadUrlRequest {
  // File ID.
  //
  // You can also specify the file's Wix media URL. For example, `wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  string file_id = 1 [(.wix.api.maxLength) = 1000];
  // Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type. <br />
  // 
  // **Note:** The name that appears in the Media Manager is taken from the `filename` parameter in the Generate File Upload Url call. 
  google.protobuf.StringValue download_file_name = 2 [(.wix.api.maxLength) = 100];
  // The time that it takes in minutes for the download URL to expire. <br />
  // Default: `600`. <br />
  // Limit: `525600` (1 year).
  google.protobuf.Int32Value expiration_in_minutes = 3 [(.wix.api.min) = 1];
  // The redirect URL for when the temporary download URL with a token expires. <br />
  // Default: A 403 Forbidden response page.
  google.protobuf.StringValue expiration_redirect_url = 4 [(.wix.api.format) = WEB_URL];
  // Keys for downloading different assets (format and quality) of a file. 
  // Default: `src`, key representing the original file's format and quality.
  repeated google.protobuf.StringValue asset_keys = 5 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 100];
  // Whether the link downloads the file or opens the file in the browser.
  //
  // - `ATTACHMENT`: The link downloads the file.
  // - `INLINE`: The link opens the file in the browser.
  //
  // Default: `ATTACHMENT`
  ContentDisposition content_disposition = 6;
}

message GenerateFileDownloadUrlResponse {
  // URL for downloading a specific file in the Media Manager.
  repeated DownloadUrl download_urls = 1 [(.wix.api.maxSize) = 100];
}

message UpdateFileRequest {
  // ID of the file to update.
  //
  // You can also specify the file's Wix media URL. For example, `wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  string file_id = 1 [(.wix.api.maxLength) = 1000];
  // File name that appears in the Media Manager.
  google.protobuf.StringValue display_name = 2 [(.wix.api.maxLength) = 200];
  /* ID of the file's parent folder. <br />
   * Default: `media-root`.
   */
  google.protobuf.StringValue parent_folder_id = 3 [(.wix.api.maxLength) = 100];
  // Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. 
  repeated google.protobuf.StringValue labels = 4  [(.wix.api.maxSize) = 500, (.wix.api.maxLength) = 200];
}

message UpdateFileResponse {
  // Information about the updated file.
  FileDescriptor file = 1;
}



message UpdateFileDescriptorRequest {
  // The file to update.
  FileDescriptor file = 1;
  // Set of fields to update. Fields that aren't included in `fieldMask.paths` are ignored. 
  google.protobuf.FieldMask field_mask = 2 [(.wix.api.field_exposure) = INTERNAL];
}

message UpdateFileDescriptorResponse {
  // Information about the updated file.
  FileDescriptor file = 1;
}


message ImageAnnotationConfigurations{
  // Whether to skip detection for the image
  google.protobuf.BoolValue skip_detection = 1;
  // A list of detections types to fill for the image
  // If specified at least one valid annotation type should be provided
  // Default will be all detections
  repeated ImageAnnotationType annotation_types = 2 [(.wix.api.maxSize) = 10];
}

message GenerateFileUploadUrlRequest {
  // File mime type. 
  google.protobuf.StringValue mime_type = 1 [(.wix.api.maxLength) = 100];

  // Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type. 
  // <br /> **Note:** The name that appears in the Media Manager is taken from the `filename` parameter in the Generate File Upload Url call.  
  google.protobuf.StringValue file_name = 2 [(.wix.api.maxLength) = 200];

  // File size in bytes.
  google.protobuf.StringValue size_in_bytes = 3 [(.wix.api.readOnly) = true, (.wix.api.format) = DECIMAL_VALUE, (.wix.api.decimalValue) = {gte: "0", maxScale: 0}];;

  /* ID of the file's parent folder. <br />
   * This folder is the path root for the `filePath`.<br />
   * Default: `media-root`.
   */
  google.protobuf.StringValue parent_folder_id = 4 [(.wix.api.maxLength) = 100];

  // Whether the file will be public or private. Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  google.protobuf.BoolValue private = 5;

  // Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. 
  repeated google.protobuf.StringValue labels = 6 [(.wix.api.maxSize) = 50, (.wix.api.maxLength) = 200];

  // A place to map an external entity to an uploaded file in the Wix Media Manager. 
  ExternalInfo external_info = 9;

  // The uploaded file will be created under this namespace
  google.protobuf.StringValue raw_namespace = 11 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // The uploaded file will be created under this namespace
  // Note - Namespace value `Others` is not supported and will produce an error
  Namespace namespace = 12 [(.wix.api.field_exposure) = INTERNAL];

  // Path to the folder where the file will be stored.
  // For example, `/videos/2024/december`. <br/>
  // If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`.
  // The folders in the path will be created if they don't already exist.  <br />
  google.protobuf.StringValue file_path = 13 [(.wix.api.maxLength) = 100];

  // Internal tags describing the item, can be used in specific clients use cases
  repeated string internal_tags = 14 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxSize) = 100, (.wix.api.maxLength) = 200];

  // The time in hours for a draft file to expire and be deleted
  // Allowed only on DRAFT namespace
  // parent folder id and file path are not allowed when using draft_ttl_in_hours
  google.protobuf.Int32Value draft_ttl_in_hours = 15 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.min) = 1];

  // Configure what annotations will be done for an image file
  ImageAnnotationConfigurations image_annotation_configurations = 16 [(.wix.api.field_exposure) = INTERNAL];
}

message GenerateFileUploadUrlResponse {
  // The URL for uploading a file to the Media Manager.
  string upload_url = 1 [(.wix.api.format) = WEB_URL];
}


message GenerateFileResumableUploadUrlRequest {
  // File mime type. 
  google.protobuf.StringValue mime_type = 1 [(.wix.api.maxLength) = 100];
  // Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type. 
  // <br /> **Note:** The name that appears in the Media Manager is taken from the `filename` parameter in the Generate File Upload Url call.  
  google.protobuf.StringValue file_name = 2 [(.wix.api.maxLength) = 200];

  // File size in bytes.
  google.protobuf.StringValue size_in_bytes = 3 [(.wix.api.readOnly) = true, (.wix.api.format) = DECIMAL_VALUE, (.wix.api.decimalValue) = {gte: "0", maxScale: 0}];;

  /* ID of the file's parent folder. <br />
   * This folder is the path root for the `filePath`.<br />
   * Default: `media-root`.
   */
  google.protobuf.StringValue parent_folder_id = 4 [(.wix.api.maxLength) = 100];

  // Whether the file will be public or private. Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  google.protobuf.BoolValue private = 5;
  // Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. 
  repeated google.protobuf.StringValue labels = 6  [(.wix.api.maxSize) = 500, (.wix.api.maxLength) = 200];


  // The upload protocol to use for implementing the resumable upload.
  UploadProtocol upload_protocol = 10;

  // The uploaded file will be created under this namespace
  google.protobuf.StringValue raw_namespace = 11 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // The uploaded file will be created under this namespace
  // Note - Namespace value `Others` is not supported and will produce an error
  Namespace namespace = 12 [(.wix.api.field_exposure) = INTERNAL];

  // Path to the folder where the file will be stored.
  // For example, `/videos/2024/december`. <br/>
  // If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`.
  // The folders in the path will be created if they don't already exist.  <br />
  google.protobuf.StringValue file_path = 13 [(.wix.api.maxLength) = 100];

  // Internal tags describing the item, can be used in specific clients use cases
  repeated string internal_tags = 14 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxSize) = 100, (.wix.api.maxLength) = 200];

  // The time in hours for a draft file to expire and be deleted
  // Allowed only on DRAFT namespace
  google.protobuf.Int32Value draft_ttl_in_hours = 15 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.min) = 1];

  // Configure what annotations will be done for an image file
  ImageAnnotationConfigurations image_annotation_configurations = 16 [(.wix.api.field_exposure) = INTERNAL];
}

message GenerateFileResumableUploadUrlResponse {
  // The upload protocol to use for implementing the resumable upload.
  UploadProtocol upload_protocol = 1;
  // The URL for uploading a file to the Media Manager.
  string upload_url = 2 [(.wix.api.format) = WEB_URL];
  // Single-use upload token.
  string upload_token = 3 [(.wix.api.maxLength) = 2000];
}



message ImportFileRequest {
  // Publicly accessible external file URL.
  string url = 1 [(.wix.api.format) = WEB_URL];

  // Media type of the file to import.
  // excluding: OTHER media type
  MediaType media_type = 2;

  // File name that appears in the Media Manager.
  google.protobuf.StringValue display_name = 3 [(.wix.api.maxLength) = 200];
  /* ID of the file's parent folder. <br />
  This folder is the path root for the `filePath`. <br />
  Default: `media-root`.
  */
  google.protobuf.StringValue parent_folder_id = 5 [(.wix.api.maxLength) = 100];
  // Whether the file will be public or private. Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  google.protobuf.BoolValue private = 6;
  // Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. 
  repeated google.protobuf.StringValue labels = 7  [(.wix.api.maxSize) = 500, (.wix.api.maxLength) = 200];
  // File mime type.
  string mime_type = 8 [(.wix.api.maxLength) = 100];

  // Information sent to the File Ready and File Failed events. See Importing Files ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_using-externalinfo) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#using-externalinfo)) to learn more.
  ExternalInfo external_info = 9;

  // Optional parameters that should be sent with the external URL.
  google.protobuf.Struct url_params = 10;

  // Optional headers that should be sent with the external URL.
  google.protobuf.Struct url_headers = 11;

  // The imported file will be created under this namespace
  google.protobuf.StringValue raw_namespace = 12 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // The imported file will be created under this namespace
  // Note - Namespace value `Others` is not supported and will produce an error
  Namespace namespace = 13 [(.wix.api.field_exposure) = INTERNAL];

  // Path to the folder where the file will be stored.
  // For example, `/videos/2024/december`. <br/>
  // If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`.
  // The folders in the path will be created if they don't already exist.  <br />
  google.protobuf.StringValue file_path = 14 [(.wix.api.maxLength) = 100];

  // Internal tags describing the item, can be used in specific clients use cases
  repeated string internal_tags = 15 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxSize) = 100, (.wix.api.maxLength) = 200];

  // The time in hours for a draft file to expire and be deleted
  // Allowed only on DRAFT namespace
  google.protobuf.Int32Value draft_ttl_in_hours = 16 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.min) = 1];

  // Configure what annotations will be done for an image file
  ImageAnnotationConfigurations image_annotation_configurations = 17 [(.wix.api.field_exposure) = INTERNAL];
}

message ImportFileResponse {
  // Information about the imported file. 
  FileDescriptor file = 1;
}


message BulkImportFilesRequest {
  // Information about the files to import.
  repeated ImportFileRequest import_file_requests = 1 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 100];
}

message BulkImportFilesResponse {
  // Information about the imported files. 
  repeated FileDescriptor files = 1 [(.wix.api.maxSize) = 100];
}

message BulkImportFileRequest {
  // Information about the files to import.
  repeated ImportFileRequest import_file_requests = 1  [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 100];
  // Whether to include the imported File Descriptor in the response. Set to `false` to exclude the File Descriptor from the response.

  //
  // Default: `true`
  google.protobuf.BoolValue return_entity = 2;
}

message BulkImportFileResult {
  // Item metadata.
  .wix.common.ItemMetadata item_metadata = 1;

  // Imported file. This field is included in the response if the operation was successful and `returnEntity` is not set to `false`.
  FileDescriptor item = 2;
}

message BulkImportFileResponse {
  // Items created by bulk action.
  repeated BulkImportFileResult results = 1;
  // Bulk action metadata.
  .wix.common.BulkActionMetadata bulk_action_metadata = 2;
}



message GetFileDescriptorRequest {
  // File ID.
  //
  // You can also specify the file's Wix media URL. For example, `wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  //
  // If you are working in REST, note that you must encode the Wix media URL to specify it as a query param because it contains special characters. For example, `wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032` becomes `wix%3Aimage%3A%2F%2Fv1%2F0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg%2Fleon.jpg%23originWidth%3D3024%26originHeight%3D4032`.
  string file_id = 1 [(.wix.api.maxLength) = 1000];
}

message GetFileDescriptorResponse {
  // Information about the file.
  FileDescriptor file = 1;
}


message GetFileDescriptorsRequest {
  // File IDs.
  //
  // You can also specify the files' Wix media URLs. For example, `["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  repeated string file_ids = 1 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 100, (.wix.api.maxLength) = 1000];
}

message GetFileDescriptorsResponse {
  // Information about the requested files.
  repeated FileDescriptor files = 1 [(.wix.api.maxSize) = 100];
}


message ListFilesRequest {
  /* 
  ID of the file's parent folder.
  
  Default: `media-root`.
  */
  google.protobuf.StringValue parent_folder_id = 1 [(.wix.api.maxLength) = 100];
  // File media type.
  repeated MediaType media_types = 3  [(.wix.api.maxSize) = 30];
  /*
  Whether to return only private or only public files.
  + `true`: Returns only private files.
  + `false`: Returns only public files.
  + `undefined`: Returns public and private files.
  
  Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  */
  google.protobuf.BoolValue private = 4;
  /*
  Field name and order to sort by. One of:

  * `displayName` 
  * `updatedDate`
  * `sizeInBytes`

  Default: `updatedDate` in `desc` order.
  */
  .wix.common.Sorting sort = 5;
  // Cursor and paging information.
  com.wix.media.site_media.upstream.wix.common.CursorPaging paging = 6;

  // List files of the specified namespace
  google.protobuf.StringValue raw_namespace = 12 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // List files of the specified namespace
  // Note - Namespace value `Others` is not supported and will produce an error
  Namespace namespace = 13 [(.wix.api.field_exposure) = INTERNAL];
}

message ListFilesResponse {
  // List of files in the Media Manager.
  repeated FileDescriptor files = 1 [(.wix.api.maxSize) = 200];
  // The next cursor if it exists.
  com.wix.media.site_media.upstream.wix.common.PagingMetadataV2 next_cursor = 2;
}


message SearchFilesRequest {

  /*
  Free text to match in searchable fields.

  For example, search for specific values in a file's 
  `displayName`, `mimeType`, or `label`.
  */
  google.protobuf.StringValue search = 1 [(.wix.api.maxLength) = 200];

  /*
  The root folder in the media manager to search in.
  For more information, see Root Folders in Terminology ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/introduction#terminology) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction#terminology)).

  Default: `MEDIA_ROOT`.
  */
  RootFolder root_folder = 2;

  // File media type.
  repeated MediaType media_types = 3  [(.wix.api.maxSize) = 30];
  
  /*
  Whether to return only private or only public files.
  + `true`: Returns only private files.
  + `false`: Returns only public files.
  + `undefined`: Returns public and private files.
  
  Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  */
  google.protobuf.BoolValue private = 4;

  /*
  Field name and order to sort by. 
  
  One of:
  * `displayName` 
  * `updatedDate`
  * `sizeInBytes`

  Default: `updatedDate` in `desc` order.
  */
  .wix.common.Sorting sort = 5;

  // Cursor and paging information.
  com.wix.media.site_media.upstream.wix.common.CursorPaging paging = 6;

  // search by an internal tag that describe the item - for internal wix use only
  google.protobuf.StringValue internal_tag = 7 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 200];

  // Search files of the specified namespace
  google.protobuf.StringValue raw_namespace = 8 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // Search files of the specified namespace <br/>
  // Note - Namespace value `Others` is not supported in this request and will produce an error
  Namespace namespace = 9 [(.wix.api.field_exposure) = INTERNAL];
}

message SearchFilesResponse {
  /*
  Retrieved files that match the search criteria specified in the request.

  Each file includes all standard file information.
  */
  repeated FileDescriptor files = 1 [(.wix.api.maxSize) = 200];
  // The next cursor if it exists.
  com.wix.media.site_media.upstream.wix.common.PagingMetadataV2 next_cursor = 2;
}

message GenerateVideoStreamingUrlRequest {
  enum StreamFormat {
    UNKNOWN = 0;
    HLS = 1;
    DASH = 2;
  }
  // File ID.
  //
  // You can also specify the file's Wix media URL. For example, `wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  string file_id = 1 [(.wix.api.maxLength) = 1000];
  // Video stream format.
  StreamFormat format = 2;
}

message GenerateVideoStreamingUrlResponse {
  // URL for streaming a specific file in the Media Manager.
  DownloadUrl download_url = 1;
}

message GenerateWebSocketTokenRequest {
}

message GenerateWebSocketTokenResponse {
  // The web socket token for the identity in the request
  string token = 1 [(.wix.api.maxLength) = 2000];
}


message BulkDeleteFilesRequest {
  // IDs of the files to move to the Media Manager's trash bin.
  //
  // You can also specify the files' Wix media URLs. For example, `["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  repeated string file_ids = 1 [(.wix.api.maxSize) = 1000, (.wix.api.maxLength) = 1000];

  // Whether the specified files are permanently deleted. <br />
  // Default: `false`
  bool permanent = 2;
}

message BulkDeleteFilesResponse {
}

message BulkRestoreFilesFromTrashBinRequest {
  // IDs of the files to restore from the Media Manager's trash bin.
  //
  // You can also specify the files' Wix media URLs. For example, `["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  repeated string file_ids = 1  [(.wix.api.maxSize) = 1000, (.wix.api.maxLength) = 1000];
}

message BulkRestoreFilesFromTrashBinResponse {
}

message ListDeletedFilesRequest {
  /* ID of the file's parent folder. <br />
   * Default: `media-root`.
   */
  google.protobuf.StringValue parent_folder_id = 1 [(.wix.api.maxLength) = 100];
  // File media type.
  repeated MediaType media_types = 3  [(.wix.api.maxSize) = 30];
  // \n`true`: Returns only private files. \n`false`: Returns only public files. \n`undefined`: Returns public and private files. \n Learn more about private files ([SDK](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files) | [REST](https://dev.wix.com/docs/sdk/backend-modules/media/files/private-files)).
  google.protobuf.BoolValue private = 4;
  // Field name and order to sort by. One of: <br />
  // * `displayName` 
  // * `updatedDate`
  // * `sizeInBytes`
  // Default: `updatedDate` in `desc` order.
  .wix.common.Sorting sort = 5;
  // Cursor and paging information.
  com.wix.media.site_media.upstream.wix.common.CursorPaging paging = 6;

  // List files of the specified namespace
  google.protobuf.StringValue raw_namespace = 7 [(.wix.api.field_exposure) = INTERNAL, (.wix.api.maxLength) = 100];

  // List files of the specified namespace
  // Note - Namespace value `Others` is not supported and will produce an error
  Namespace namespace = 8 [(.wix.api.field_exposure) = INTERNAL];
}

message ListDeletedFilesResponse {
  // List of files in the Media Manager's trash bin. 
  repeated FileDescriptor files = 1 [(.wix.api.maxSize) = 200];
  // The next cursor if it exists.
  com.wix.media.site_media.upstream.wix.common.PagingMetadataV2 next_cursor = 2;
}

message FileFailed {
  // External information specified in the file import or upload.
  ExternalInfo external_info = 1;
  // Error information.
  .wix.api.ApplicationError error = 2;
}

message ExternalInfo{
  // External information to specify in the File Ready or File Failed events. 
  string origin = 1 [(.wix.api.maxLength) = 1000];
  // External IDs to specify in the File Ready or File Failed events. 
  repeated string external_ids = 2 [(.wix.api.maxSize) = 30, (.wix.api.maxLength) = 4000];
}

message FileReady {
  // File entity that is ready with full information.
  FileDescriptor file = 1;
  // External information specified in the file import or upload.
  ExternalInfo external_info = 2;
  // File was restored from the trash-bin.
  bool triggered_by_undelete = 3;
}


message BulkAnnotateImagesRequest {
  // The file ids to run detection on
  repeated string file_ids = 1 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 10, (.wix.api.maxLength) = 1000];
  // A list of detections types to fill for the image
  repeated ImageAnnotationType annotation_types = 2 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 10];
  // When true the endpoint will detect listed information even if the image has this information
  google.protobuf.BoolValue overwrite = 3;
  // Should the response return the item following the operation
  bool return_entity = 4;
}

message BulkAnnotateImageResult {
  // Item metadata
  .wix.common.ItemMetadata item_metadata = 1;

  // The item following the operation
  // Only returned if operation was successful and if returnEntity flag was on
  FileDescriptor item = 2;
}

message BulkAnnotateImagesResponse {
  // Results of individual items
  repeated BulkAnnotateImageResult results = 1;
  // Metadata of the operation
  .wix.common.BulkActionMetadata bulk_action_metadata = 2;
}

message BulkPublishDraftFilesRequest {
  // IDs of the draft files to be published.
  //
  // You can also specify the files' Wix media URLs. For example, `["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]`.
  // Learn more about the file ID parameter ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/file-and-folder-ids#file-id-as-a-parameter) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/file-id#file-id-as-a-parameter)).
  repeated string file_ids = 1 [(.wix.api.maxSize) = 100, (.wix.api.maxLength) = 1000];
  // The namespace the files will be published to
  // Note, private files must have a namespace
  Namespace namespace = 2;

  /* ID of the file's parent folder. <br />
  This folder is the path root for the `filePath`. <br />
  Default: `media-root`.
  */
  google.protobuf.StringValue parent_folder_id = 3 [(.wix.api.maxLength) = 100];

  // Path to the folder where the file will be stored.
  // For example, `/videos/2024/december`. <br/>
  // If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`.
  // The folders in the path will be created if they don't already exist.  <br />
  google.protobuf.StringValue file_path = 4 [(.wix.api.maxLength) = 100];
  // Should the response return the item following the operation
  bool return_entity = 5;
}

message BulkPublishDraftFileResult {
  // Item metadata
  .wix.common.ItemMetadata item_metadata = 1;

  // The item following the operation
  // Only returned if operation was successful and if returnEntity flag was on
  FileDescriptor item = 2;
}

message BulkPublishDraftFilesResponse {
  // Results of individual items
  repeated BulkPublishDraftFileResult results = 1;
  // Metadata of the operation
  .wix.common.BulkActionMetadata bulk_action_metadata = 2;
}


message DraftFilePublished {
  option (.wix.api.action_payload).custom_slug = "draft_published";
  // The file after it was published
  FileDescriptor file = 1;
  // The namespace the file was published to
  Namespace namespace = 2;
}

service FilesService {
  option (.wix.api.service_maturity) = GA;
  option (.wix.api.service_exposure) = PUBLIC;
  option (.wix.api.service_entity).message = "com.wix.media.site_media.v1.FileDescriptor";

  // Run Image Annotation process on provided list of file ids
  // Note - the processes of this endpoint are synchronous and may take time to complete
  rpc BulkAnnotateImages (BulkAnnotateImagesRequest) returns (BulkAnnotateImagesResponse) {
    option (.wix.api.exposure) = INTERNAL;
    option (.wix.api.required) = "BulkAnnotateImagesRequest.file_ids";
    option (.wix.api.required) = "BulkAnnotateImagesRequest.annotation_types";
    option (google.api.http) = {post: "/v1/bulk/files/images/annotate"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_IMAGE_DETECTION";
  }



  // Generates a URL for downloading a compressed file containing specific files in the Media Manager.
  //
  // The compressed file can contain up to 1000 files.
  //
  // To generate a permanent URL for downloading a compressed file that contains multiple files in the Media Manager, call the Generate Files Download URL endpoint.
  // Since this is a permanent URL, it is less secure.
  // Therefore, to download private files, call the Generate File Download URL endpoint for each private file that you want to generate a download URL for.
  rpc GenerateFilesDownloadUrl (GenerateFilesDownloadUrlRequest) returns (GenerateFilesDownloadUrlResponse) {
    option (.wix.api.required) = "GenerateFilesDownloadUrlRequest.file_ids";
    option (google.api.http) = {post: "/v1/files/generate-download-url"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_DOWNLOAD";
  }

  // Generates one or more temporary URLs for downloading a specific file in the Media Manager.
  // 
  // To download different assets of the file, specify the `assetKeys` parameter which generates a download URL for each asset. 
  // If no `assetKey` is specified, it defaults to `src`, which generates one download URL in the original file's format and quality.
  //   
  // Call this endpoint to grant external clients access to a private media file. Specify the `expirationInMinutes` parameter to set the URL expiration time, and the `expirationRedirectUrl` parameter to add a redirect url when the URL expires. 
  //
  // To generate a permanent URL for downloading a compressed file that contains multiple files in the Media Manager, call the Generate Files Download URL endpoint.
  // Since this is a permanent URL, it is less secure.
  // Therefore, to download private files, call the Generate File Download URL endpoint for each private file that you want to generate a download URL for.
  rpc GenerateFileDownloadUrl (GenerateFileDownloadUrlRequest) returns (GenerateFileDownloadUrlResponse) {
    option (.wix.api.required) = "GenerateFileDownloadUrlRequest.file_id";
    option (google.api.http) = {
      post: "/v1/files/generate-file-download-url"
      additional_bindings: {
        post: "/v1/files/{file_id}/generate-download-url"
      }
    };

    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_DOWNLOAD_URL";

    // When one or more asset keys are unsupported
    option (.wix.api.custom_validation_error) = {
      rule_name: "INVALID_ASSET_KEY"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

  }

  // Gets information about a specific file in the Media Manager. 
  rpc GetFileDescriptor (GetFileDescriptorRequest) returns (GetFileDescriptorResponse) {
    option (.wix.api.required) = "GetFileDescriptorRequest.file_id";
    option (google.api.http) = {
      get: "/v1/files/get-file-by-id"
      additional_bindings: {
        get: "/v1/files/{file_id}"
      }
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_READ";
    // File could not be found
    option (.wix.api.custom_validation_error) = {
      rule_name: "RESOURCE_NOT_FOUND"
      data: "com.wix.media.site_media.v1.ServiceError"
    };
    option (.wix.api.crud) = {
      method: GET_ITEM
      get_options: {
        id_field: "file_id"
        item_field: "file"
      }
    };
  }
  // Gets information about specific files in the Media Manager.
  rpc GetFileDescriptors (GetFileDescriptorsRequest) returns (GetFileDescriptorsResponse) {
    option (.wix.api.required) = "GetFileDescriptorsRequest.file_ids";
    option (google.api.http) = {post: "/v1/files/get-files"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_READ";
    // File could not be found
    option (.wix.api.custom_validation_error) = {
      rule_name: "RESOURCE_NOT_FOUND"
      data: "com.wix.media.site_media.v1.ServiceError"
    };
  }

  // Updates a file. <br />
  //
  // Specify the `parentFolderId` parameter to move a file from its current folder to a different folder.
  rpc UpdateFileDescriptor (UpdateFileDescriptorRequest) returns (UpdateFileDescriptorResponse) {
    // Triggered when a file is updated, including when a file is moved to a different folder.
    option (.wix.api.callback) = {
      event_type: UPDATED
    };
    option (.wix.api.required) = "UpdateFileDescriptorRequest.file";
    option (.wix.api.required) = "UpdateFileDescriptorRequest.file.id";

    option (google.api.http) = {
      patch: "/v1/files/update-file-descriptor"
      additional_bindings: {
        patch: "/v1/files/{file.id}/update"
      }
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_UPDATE";
    option (.wix.http.infer_fieldmask) = {
      from: "file"
      fieldmask: "field_mask"
    };
    // Field mask field is empty or missing from the request
    option (.wix.api.custom_validation_error) = {
      rule_name: "FIELD_MASK_IS_EMPTY_OR_MISSING"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };

    option (.wix.api.crud) = {
      method: UPDATE
      update_options: {
        item_field: "file"
        fieldmask_field: "field_mask"
      }
    };
  }

  // Generates an upload URL to allow external clients to upload a file to the Media Manager. <br/>
  // 
  // To learn how external clients can use the generated upload URL in the response to upload a file to the Media Manager, see Upload API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/upload-api) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/upload-api)). 
  // > **Notes:** 
  // > - When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_knowing-when-a-file-is-ready) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#knowing-when-a-file-is-ready)).
  // > - Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, call Generate File Resumable Upload URL instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption. 
  rpc GenerateFileUploadUrl (GenerateFileUploadUrlRequest) returns (GenerateFileUploadUrlResponse) {
    option (.wix.api.required) = "GenerateFileUploadUrlRequest.mime_type";
    option (google.api.http) = {post: "/v1/files/generate-upload-url"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_UPLOAD";

    // MimeType is not matching the file extension
    option (.wix.api.custom_validation_error) = {
      rule_name: "MISMATCH_MIME_TYPE"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File size is zero
    option (.wix.api.custom_validation_error) = {
      rule_name: "ZERO_FILE_SIZE"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File format is recognized but unsupported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_FILE_FORMAT"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File size is over allowed size for the media type
    option (.wix.api.custom_validation_error) = {
      rule_name: "FILE_SIZE_OVER_LIMIT"
      data: "com.wix.media.site_media.v1.ServiceError"
    };
    // The site quota is or will exceed the limit
    option (.wix.api.custom_validation_error) = {
      rule_name: "SITE_QUOTA_EXCEEDED"
      data: "com.wix.media.site_media.v1.SiteQuotaExceededError"
    };
  }

  // Generates a resumable upload URL to allow external clients to easily upload large files over 10MB to the Media Manager. <br/>
  //
  // With the resumable upload URL, any interruptions in the upload process pauses the file upload, and resumes the file upload process after the interruption. The resumable upload URL is also helpful when network connection is poor. 
  // To learn how external clients can use the generated upload URL in the response to upload large files to the Media Manager, see Resumable Upload API ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/resumable-upload-api) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/resumable-upload-api)). 
  //
  // > **Note:** When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_knowing-when-a-file-is-ready) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#knowing-when-a-file-is-ready)).
  rpc GenerateFileResumableUploadUrl (GenerateFileResumableUploadUrlRequest) returns (GenerateFileResumableUploadUrlResponse) {
    option (.wix.api.required) = "GenerateFileResumableUploadUrlRequest.mime_type";
    option (google.api.http) = {post: "/v1/files/generate-resumable-upload-url"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_UPLOAD";

    // MimeType is not matching the file extension
    option (.wix.api.custom_validation_error) = {
      rule_name: "MISMATCH_MIME_TYPE"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File size is zero
    option (.wix.api.custom_validation_error) = {
      rule_name: "ZERO_FILE_SIZE"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File format is recognized but unsupported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_FILE_FORMAT"
      data: "com.wix.media.site_media.v1.ServiceError"
    };

    // File size is over allowed size for the media type
    option (.wix.api.custom_validation_error) = {
      rule_name: "FILE_SIZE_OVER_LIMIT"
      data: "com.wix.media.site_media.v1.ServiceError"
    };
  }
  // Imports a file to the Media Manager using an external url.
  // 
  // Returns information about the imported file.
  // Specify the `parentFolderId` and `filePath` parameters to specify which folder you want the file to be imported to. 
  // If no folder is specified, the file is imported to the `media-root` folder. 
  //
  // >**Notes:**
  // > - The `media` property isn't returned in the `files` response object. 
  // > - When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_knowing-when-a-file-is-ready) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#knowing-when-a-file-is-ready)).
  //
  // To import a file, you need to do one of the following: 
  // - Specify its [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` field of the request. For example, `mimeType: 'image/jpeg'`.
  // - Specify its extension in either the `displayName` or `url` field of the request. For example, `displayName: 'Example Image.jpeg` or `url: https://www.example.com/image.jpeg`.
  // - Ensure the server hosting the file supports HEAD requests. In these cases the Wix servers can retrieve the MIME type from the hosting server.
  //     > **Note:** If you want to validate the media type, specify the file's expected media type in the optional `mediaType` field of the request.  For example, `mediaType: 'IMAGE'`.
  rpc ImportFile (ImportFileRequest) returns (ImportFileResponse) {
    // Triggered when a file is ready to be used, after any post-upload processing.
    // 
    // This event is also triggred when a file is restored from the Media Manager's trash bin.
    option (.wix.api.callback) = {
      event_type: ACTION
      payload: "com.wix.media.site_media.v1.FileReady"
    };
    // Triggered when a file fails during essential post-upload processing.
    option (.wix.api.callback) = {
      event_type: ACTION
      payload: "com.wix.media.site_media.v1.FileFailed"
    };
    option (.wix.api.required) = "ImportFileRequest.url";
    option (google.api.http) = {post: "/v1/files/import"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_IMPORT";
    // The filter media type is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "SITE_QUOTA_EXCEEDED"
      data: "com.wix.media.site_media.v1.SiteQuotaExceededError"
    };
  }

  
  // Imports a bulk of files to the Media Manager using external urls. <br/>
  //
  // Returns information about the imported files. 
  //
  // Use the `parentFolderId` and `filePath` parameters to specify the folder you want each file to be imported to.
  // If no folder is specified, the file is imported to the `media-root` folder.
  //
  // >**Notes:** 
  // > - The `media` property isn't returned in the `files` response object.
  // > - When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_knowing-when-a-file-is-ready) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#knowing-when-a-file-is-ready)).
  //
  // To import files, you need to do one of the following for each file: 
  // - Specify its [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` field of the request. For example, `mimeType: 'image/jpeg'`.
  // - Include its extension in either the `displayName` or `url` field of the request. For example, `displayName: 'Example Image.jpeg` or `url: https://www.example.com/image.jpeg`.
  // - Ensure the server hosting the file supports HEAD requests. In these cases the Wix servers can retrieve the MIME type from the hosting server.
  //     > **Note:** If you want to validate the media type, specify the file's expected media type in the optional `mediaType` field of the request.  For example, `mediaType: 'IMAGE'`.
  rpc BulkImportFiles (BulkImportFilesRequest) returns (BulkImportFilesResponse) {
    option (.wix.api.required) = "BulkImportFilesRequest.import_file_requests";
    option (.wix.api.required) = "BulkImportFilesRequest.import_file_requests.url";
    option (google.api.http) = {post: "/v1/bulk/files/import"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_IMPORT";
    option (.wix.api.deprecated) = {
      replaced_by: "com.wix.media.site_media.v1.FilesService.BulkImportFile" // relative, or: "entity_fqdn.action" as absolute identifier
      target_removal_date: "2024-03-31"
    };
  }


  // Imports a bulk of files to the Media Manager using external urls. <br/>
  //
  // Returns information about the imported files. 
  //
  // Specify the `parentFolderId` and `filePath` parameters to specify the folder you want each file to be imported to.
  // If no folder is specified, the file is imported to the `media-root` folder.
  //
  // >**Notes:** 
  // > - The `media` property isn't returned in the `files` response object.
  // > - When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready ([SDK](https://dev.wix.com/docs/sdk/backend-modules/media/files/importing-files#backend-modules_media_files_knowing-when-a-file-is-ready) | [REST](https://dev.wix.com/docs/rest/assets/media/media-manager/files/importing-files#knowing-when-a-file-is-ready)).
  //
  // To import files, you need to do one of the following for each file: 
  // - Specify its [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` field of the request. For example, `mimeType: 'image/jpeg'`.
  // - Include its extension in either the `displayName` or `url` field of the request. For example, `displayName: 'Example Image.jpeg` or `url: https://www.example.com/image.jpeg`.
  // - Ensure the server hosting the file supports HEAD requests. In these cases the Wix servers can retrieve the MIME type from the hosting server.
  //     > **Note:** If you want to validate the media type, specify the file's expected media type in the optional `mediaType` field of the request.  For example, `mediaType: 'IMAGE'`.
  rpc BulkImportFile (BulkImportFileRequest) returns (BulkImportFileResponse) {
    // Triggered when a file is ready to be used, after any post-upload processing.
    // 
    // This event is also triggred when a file is restored from the Media Manager's trash bin.
    option (.wix.api.callback) = {
      event_type: ACTION
      payload: "com.wix.media.site_media.v1.FileReady"
    };
    // Triggered when a file fails during essential post-upload processing.
    option (.wix.api.callback) = {
      event_type: ACTION
      payload: "com.wix.media.site_media.v1.FileFailed"
    };
    option (.wix.api.required) = "BulkImportFileRequest.import_file_requests";
    option (.wix.api.required) = "BulkImportFileRequest.import_file_requests.url";
    option (google.api.http) = {post: "/v1/bulk/files/import-v2"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_IMPORT";
  }


  // Retrieves a list of files in the Media Manager. 
  //
  // To retrieve a list of files within a specific folder in the Media Manager, specify the folder's ID in the `parentFolderId` parameter. If no folder is specified, the method retrieves the list of files in the root folder of the Media Manager.
  rpc ListFiles (ListFilesRequest) returns (ListFilesResponse){
    option (google.api.http) = {get: "/v1/files"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_LIST";

    // The filter media type is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_MEDIA_TYPE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
    // Sort value is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_SORT_VALUE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
    // cannot add CRUD annotations because we don't use a query object
  }

  /*
  Retrieves a list of up to 200 files with the specified filtering, sorting, and cursor paging.

  If no parameters are specified, the method returns all files in the `MEDIA_ROOT` folder. 

  ## Defaults

  Search Files has the following default setting, which you can override:
  + Sorted by `updatedDate` in descending order.

  ## Filters

  When using filters for dates, you must use
  [UTC time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).
  
  ## See also

  To learn about working with *Search* methods, see
  _API Query Language_
  ([SDK](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/api-query-language) | [REST](https://dev.wix.com/docs/rest/articles/get-started/api-query-language))
  and *Sorting and Paging*
  ([SDK](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/api-query-language#the-sort-array) | [REST](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging)).
  */
  rpc SearchFiles (SearchFilesRequest) returns (SearchFilesResponse){
    option (google.api.http) = {post: "/v1/files/search"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_LIST";

    // The filter media type is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_MEDIA_TYPE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
    // Sort value is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_SORT_VALUE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
  }

  // Generates a URL for streaming a specific video file in the Media Manager. <br/>
  //
  // To stream different assets of the file, specify the `assetKeys` parameter which generates a video streaming URL for each asset. If no assetKey is specified, it defaults to `src`, which generates one video streaming URL in the original file's format and quality.
  rpc GenerateVideoStreamingUrl (GenerateVideoStreamingUrlRequest) returns (GenerateVideoStreamingUrlResponse){
    option (.wix.api.required) = "GenerateVideoStreamingUrlRequest.file_id";
    option (google.api.http) = {
      post: "/v1/files/generate-video-stream-url"
      additional_bindings: {
        post: "/v1/files/video/{file_id}/generate-stream-url"
      }
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_READ";

  }

  // Return a token for a direct web socket notification channel
  // This API is not platformized (Contact the Media team for use instructions)
  // This API should be internal only
  rpc GenerateWebSocketToken (GenerateWebSocketTokenRequest) returns (GenerateWebSocketTokenResponse){
    option (.wix.api.exposure) = INTERNAL;
    option (google.api.http) = {post: "/v1/files/generate-web-socket-token"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_WEB_NOTIFICATIONS_TOKEN";

  }

  // Deletes the specified files from the Media Manager. <br/>
  //
  // The deleted files are moved to the Media Manager's trash bin (`TRASH-ROOT` folder) unless permanently deleted. To permanently delete files, specify the `permanent` parameter with the value `true`. Permanently deleting files isn't reversible, so make sure that these files aren't being used in a site or in any other way as the files will no longer be accessible.
  //
  // Note the following:
  // * The specified files can be from different folders.
  // * Moving multiple files at once is an asynchronous action, and may take time for the changes to appear in the Media Manager.
  // * Attempting to delete files that are already in the trash bin doesn't result in an error.
  // * If a site contains deleted media files, the deleted media files still appear on the site as the files are still in the Media Manager (in the trash bin).
  // * You can use Bulk Restore Files From Trash Bin to restore files from the Media Manager's trash bin. 
  rpc BulkDeleteFiles (BulkDeleteFilesRequest) returns (BulkDeleteFilesResponse) {
    // Triggered when a file is deleted.
    // 
    // If the `movedToTrash` property in the event object `true`, the file was moved to the Media Manager's trash bin. If the `movedToTrash` property in the event object is `false`, the file was permanently deleted.
    option (.wix.api.callback) = {
      event_type: DELETED
    };
    option (.wix.api.required) = "BulkDeleteFilesRequest.file_ids";
    option (google.api.http) = {post: "/v1/bulk/files/delete"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_MOVE_TO_TRASH";
    option (.wix.api.crud) = {
      method: BULK_DELETE
      bulk_delete_options: {
        ids_field: "file_ids"
      }
    };
  }

  // Restores the specified files from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
  rpc BulkRestoreFilesFromTrashBin(BulkRestoreFilesFromTrashBinRequest) returns (BulkRestoreFilesFromTrashBinResponse) {
    // Triggered when a file is ready to be used, after any post-upload processing.
    // 
    // This event is also triggred when a file is restored from the Media Manager's trash bin.
    option (.wix.api.callback) = {
      event_type: ACTION
      payload: "com.wix.media.site_media.v1.FileReady"
    };
    option (.wix.api.required) = "BulkRestoreFilesFromTrashBinRequest.file_ids";
    option (google.api.http) = {
      post : "/v1/bulk/trash-bin/files/restore"
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_RESTORE_FROM_TRASH";
  }

  // Retrieves a list of files in the Media Manager's trash bin. <br/>
  // 
  // >**Note:** The Media Manager's trash bin (`TRASH-ROOT` folder) only contains temporarily deleted files, not permanently deleted files.
  rpc ListDeletedFiles(ListDeletedFilesRequest) returns (ListDeletedFilesResponse) {
    option (google.api.http) = {
      get : "/v1/trash-bin/files"
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_LIST_DELETED";
    // The filter media type is not supported
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_MEDIA_TYPE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
    option (.wix.api.custom_validation_error) = {
      rule_name: "UNSUPPORTED_SORT_VALUE"
      data: "com.wix.media.site_media.v1.UnsupportedRequestValueError"
    };
    // cannot add CRUD annotations because we don't use a query object
  }

  rpc BulkPublishDraftFiles(BulkPublishDraftFilesRequest) returns (BulkPublishDraftFilesResponse) {
    option (.wix.api.exposure) = INTERNAL;
    option (.wix.api.emits) = {
      event_type: ACTION
      action_message_fqn: "com.wix.media.site_media.v1.DraftFilePublished"
    };
    option (.wix.api.required) = "BulkPublishDraftFilesRequest.file_ids";
    option (google.api.http) = {post: "/v1/bulk/files/publish-drafts"};
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_PUBLISH";
  }

  /* Updates a file.
  * 
  *   Specify the `parentFolderId` parameter to move a file from its current folder to a different folder.
  */
  rpc UpdateFile (UpdateFileRequest) returns (UpdateFileResponse) {
    option (.wix.api.deprecated) = {
      replaced_by: "com.wix.media.site_media.v1.FilesService.UpdateFileDescriptor"
      target_removal_date: "2023-03-31"
    };
    option (.wix.api.required) = "UpdateFileRequest.file_id";
    option (google.api.http) = {
      patch: "/v1/files/update-file"
      additional_bindings: {
        patch: "/v1/files/{file_id}"
      }
    };
    option (.wix.api.permission).name = "MEDIA.SITE_MEDIA_FILES_UPDATE";
  }

  option (.wix.api.event) = {
    event_type: UPDATED
  };

  option (.wix.api.event) = {
    event_type: DELETED
  };

  option (.wix.api.event) = {
    event_type: ACTION
    payload: "com.wix.media.site_media.v1.FileReady"
  };

  option (.wix.api.event) = {
    event_type: ACTION
    payload: "com.wix.media.site_media.v1.FileFailed"
  };
}
