syntax = "proto3";

package com.wixpress.vi.localization.translator;

import "com/wixpress/vi/localization/translator/content.proto";
import "wix/api/callback.proto";
import "wix/api/validations.proto";
import "wix/api/sla.proto";
import "wix/api/annotations.proto";
import "wix/api/permissions.proto";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "wix/api/entity.proto";
import "google/protobuf/wrappers.proto";

service ContentService {
    option (wix.api.service_entity).message = "com.wixpress.vi.localization.translator.Content";
    /*
    Uploads original source content to Smartling. Re-uploading content with the same contentUri will override the
     previous one, but keep the already translated strings within it. It means that if you wish to partially update
     content, simply re-upload it with the same contentUri and the new strings (including the old strings).
    */
    rpc UploadSourceContent (UploadRequest) returns (UploadResponse) {
        option (google.api.http).post = "/api/content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "UploadRequest.content";
        option (wix.api.required) = "UploadRequest.content.content_uri";
        option (wix.api.required) = "UploadRequest.content.text";
        option (wix.api.required) = "UploadRequest.content.text.content";
        option (wix.api.required) = "UploadRequest.content.text.format";
        option (wix.api.required) = "UploadRequest.config";
        option (wix.api.required) = "UploadRequest.config.smartling_project_id";
    }

    rpc UploadSourceContentV2 (UploadRequestV2) returns (UploadResponse) {
        option (google.api.http).post = "/api/content/v2/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "UploadRequestV2.content";
        option (wix.api.required) = "UploadRequestV2.content.content_uri";
        option (wix.api.required) = "UploadRequestV2.content.text";
        option (wix.api.required) = "UploadRequestV2.content.text.content";
        option (wix.api.required) = "UploadRequestV2.content.text.format";
        option (wix.api.required) = "UploadRequestV2.config";
        option (wix.api.required) = "UploadRequestV2.config.smartling_project_id";
    }

    /*
    Get translated content in the requested locales.
     Strings that were not yet translated will be provided in their original source language.
    */
    rpc GetTranslatedContent (GetTranslatedContentRequest) returns (GetTranslatedContentResponse) {
        option (google.api.http).get = "/api/content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";
        option (wix.api.sla).response_time_ms = 900000;
        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetTranslatedContentRequest.config.smartling_project_id";
        option (wix.api.required) = "GetTranslatedContentRequest.content_uri";
        option (wix.api.required) = "GetTranslatedContentRequest.locales";
    }

    /*
    Get translated content in the requested locales.
    Strings that were not yet translated will be provided in their original source language.
    */
    rpc GetAllTranslatedContent (GetAllTranslatedContentRequest) returns (GetTranslatedContentResponse) {
        option (google.api.http).get = "/api/content/v1/all/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetAllTranslatedContentRequest.config.smartling_project_id";
        option (wix.api.required) = "GetAllTranslatedContentRequest.content_uri";
    }

    rpc GetAllTranslatedContentV2 (GetAllTranslatedContentRequestV2) returns (GetTranslatedContentResponse) {
        option (google.api.http).get = "/api/content/v2/all/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetAllTranslatedContentRequestV2.config.smartling_project_id";
        option (wix.api.required) = "GetAllTranslatedContentRequestV2.content_uri";
    }

    /*
    Removes the content from Smartling. The content will no longer be available for download.
     Any complete translations for the file remain available for use within the system.
    */
    rpc DeleteContent (DeleteContentRequest) returns (DeleteContentResponse) {
        option (google.api.http).delete = "/api/content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "DeleteContentRequest.config.smartling_project_id";
        option (wix.api.required) = "DeleteContentRequest.content_uri";
    }

    /*
    Renames an uploaded content by changing the contentUri.
     After renaming the content, it will only be identified by the new contentUri that you provide.
    */
    rpc RenameContent (RenameContentRequest) returns (RenameContentResponse) {
        option (google.api.http).patch = "/api/content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "RenameContentRequest.config.smartling_project_id";
        option (wix.api.required) = "RenameContentRequest.content_uri";
        option (wix.api.required) = "RenameContentRequest.new_content_uri";
    }

    /*
    Get translated content, for a single file in a single locale.
    */
    rpc GetTranslatedContentForSingleFile (GetTranslatedContentForSingleFileRequest) returns (GetTranslatedContentForSingleFileResponse) {
        option (google.api.http).get = "/api/single-content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetTranslatedContentForSingleFileRequest.config.smartling_project_id";
        option (wix.api.required) = "GetTranslatedContentForSingleFileRequest.content_uri";
        option (wix.api.required) = "GetTranslatedContentForSingleFileRequest.locale";
    }

    /*
    Get source content (en)
    */
    rpc GetSourceContent (GetSourceContentRequest) returns (GetSourceContentResponse) {
        option (google.api.http).get = "/api/source-content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetSourceContentRequest.config.smartling_project_id";
        option (wix.api.required) = "GetSourceContentRequest.content_uri";
    }

    /*
    Get last modified locales in the project
    */
    rpc GetLastModifiedLocales (GetLastModifiedRequest) returns (GetLastModifiedResponse) {
        option (google.api.http).get = "/api/modified-content/v1/{config.smartling_project_id}";
        option (wix.api.permission).name = "TRANSLATOR.USER_VALIDATION";

        option (wix.api.exposure) = INTERNAL;
        option (wix.api.maturity) = ALPHA;

        option (wix.api.required) = "GetLastModifiedRequest.config.smartling_project_id";
    }
}

message UploadRequest {
    // The content that needs to be translated, in the source language (English)
    Content content = 1;

    // Configuration that defines a client
    ClientConfig config = 2;

    /*
     Determines whether the content is automatically authorized (available for translation) in all locales upon upload.
      If set to false, a manual authorization must occur within Smartling
    */
    bool authorize = 3;

    // Optional additional formatting rules for the translators
    Directives directives = 4;
}

message UploadRequestV2 {
    // The content that needs to be translated, in the source language (English)
    Content content = 1;

    // Configuration that defines a client
    ClientConfig config = 2;

    /*
     Determines whether the content is automatically authorized (available for translation) in all locales upon upload.
      If set to false, a manual authorization must occur within Smartling
    */
    .google.protobuf.BoolValue authorize = 3;

    // Optional additional formatting rules for the translators
    Directives directives = 4;
}

message UploadResponse {
}

message GetTranslatedContentRequest {
    // The unique content uri provided during the upload flow
    string content_uri = 1;

    // Requested languages for the translations
    repeated string locales = 2 [(wix.api.minSize) = 1];

    // Configuration that defines a client
    ClientConfig config = 3;

    // Get all strings or only the translated strings
    bool includeTranslatedStringsOnly = 4;
}

message GetAllTranslatedContentRequest {
    // The unique content uri provided during the upload flow
    string content_uri = 1;

    // Configuration that defines a client
    ClientConfig config = 2;

    // Get all strings or only the translated strings
    bool includeTranslatedStringsOnly = 3;
}

message GetAllTranslatedContentRequestV2 {
    // The unique content uri provided during the upload flow
    string content_uri = 1;

    // Configuration that defines a client
    ClientConfig config = 2;

    // Get all strings or only the translated strings
    bool includeOriginalStrings = 3;
}

message GetTranslatedContentResponse {
    // List of translated content
    repeated Content content = 1;
}

message GetTranslatedContentForSingleFileRequest {
    // The unique content uri provided during the upload flow
    string content_uri = 1;

    // Requested language for the translation
    string locale = 2;

    // Configuration that defines a client
    ClientConfig config = 3;

    // Get all strings or only the translated strings
    bool includeTranslatedStringsOnly = 4;
}

message GetTranslatedContentForSingleFileResponse {
    // Translated content
    Content content = 1;
}

message DeleteContentRequest {
    // Configuration that defines a client
    ClientConfig config = 1;

    // The unique content uri provided during the upload flow
    string content_uri = 2;
}

message DeleteContentResponse {
}

message RenameContentRequest {
    // Configuration that defines a client
    ClientConfig config = 1;

    // Current value that uniquely identifies the content
    string content_uri = 2;

    /*
    The new value for contentUri. We recommend that you use file path and file name,
    similar to how version control systems identify the file.
    This must be a contentUri that does not exist in the current Smartling project.
    */
    string new_content_uri = 3;
}

message RenameContentResponse {
}

message GetSourceContentRequest {
    // The unique content uri provided during the upload flow
    string content_uri = 1;

    // Configuration that defines a client
    ClientConfig config = 2;
}

message GetSourceContentResponse {
    // Original content
    SourceContent content = 1;
}

message GetLastModifiedRequest {
    ClientConfig config = 1;
    string contentUri = 2;
    string lastModifiedAfter = 3;
}

message GetLastModifiedResponse {
    repeated string locales = 1;
}