import "common_base.proto";
import "common.proto";

message CCloud_AppCloudStateChange_Notification {
	optional uint32 appid = 1;
	optional uint64 app_change_number = 2;
}

message CCloud_AppFileInfo {
	optional string file_name = 1;
	optional bytes sha_file = 2;
	optional uint64 time_stamp = 3;
	optional uint32 raw_file_size = 4;
	optional int32 persist_state = 5 [(.description) = "enum"];
	optional uint32 platforms_to_sync = 6;
	optional uint32 path_prefix_index = 7;
	optional uint32 machine_name_index = 8;
}

message CCloud_AppLaunchIntent_Request {
	optional uint32 appid = 1;
	optional uint64 client_id = 2;
	optional string machine_name = 3;
	optional bool ignore_pending_operations = 4;
	optional int32 os_type = 5;
	optional int32 device_type = 6;
}

message CCloud_AppLaunchIntent_Response {
	repeated .CCloud_PendingRemoteOperation pending_remote_operations = 1;
}

message CCloud_AppSessionResume_Request {
	optional uint32 appid = 1;
	optional uint64 client_id = 2;
}

message CCloud_AppSessionResume_Response {
}

message CCloud_AppSessionSuspend_Request {
	optional uint32 appid = 1;
	optional uint64 client_id = 2;
	optional string machine_name = 3;
	optional bool cloud_sync_completed = 4;
}

message CCloud_AppSessionSuspend_Response {
}

message CCloud_BeginAppUploadBatch_Request {
	optional uint32 appid = 1;
	optional string machine_name = 2;
	repeated string files_to_upload = 3;
	repeated string files_to_delete = 4;
	optional uint64 client_id = 5;
	optional uint64 app_build_id = 6;
}

message CCloud_BeginAppUploadBatch_Response {
	optional uint64 batch_id = 1;
	optional uint64 app_change_number = 4;
}

message CCloud_BeginHTTPUpload_Request {
	optional uint32 appid = 1;
	optional uint32 file_size = 2;
	optional string filename = 3;
	optional string file_sha = 4;
	optional bool is_public = 5;
	repeated string platforms_to_sync = 6;
	repeated string request_headers_names = 7;
	repeated string request_headers_values = 8;
	optional uint64 upload_batch_id = 9;
}

message CCloud_BeginHTTPUpload_Response {
	optional fixed64 ugcid = 1;
	optional fixed32 timestamp = 2;
	optional string url_host = 3;
	optional string url_path = 4;
	optional bool use_https = 5;
	repeated .CCloud_BeginHTTPUpload_Response_HTTPHeaders request_headers = 6;
}

message CCloud_BeginHTTPUpload_Response_HTTPHeaders {
	optional string name = 1;
	optional string value = 2;
}

message CCloud_BeginUGCUpload_Request {
	optional uint32 appid = 1;
	optional uint32 file_size = 2;
	optional string filename = 3;
	optional string file_sha = 4;
	optional string content_type = 5;
}

message CCloud_BeginUGCUpload_Response {
	optional int32 storage_system = 1 [(.description) = "enum"];
	optional fixed64 ugcid = 2;
	optional fixed32 timestamp = 3;
	optional string url_host = 4;
	optional string url_path = 5;
	optional bool use_https = 6;
	repeated .CCloud_BeginUGCUpload_Response_HTTPHeaders request_headers = 7;
}

message CCloud_BeginUGCUpload_Response_HTTPHeaders {
	optional string name = 1;
	optional string value = 2;
}

message CCloud_CDNReport_Notification {
	optional fixed64 steamid = 1;
	optional string url = 2;
	optional bool success = 3;
	optional uint32 http_status_code = 4;
	optional uint64 expected_bytes = 5;
	optional uint64 received_bytes = 6;
	optional uint32 duration = 7;
}

message CCloud_ClientBeginFileUpload_Request {
	optional uint32 appid = 1;
	optional uint32 file_size = 2;
	optional uint32 raw_file_size = 3;
	optional bytes file_sha = 4;
	optional uint64 time_stamp = 5;
	optional string filename = 6;
	optional uint32 platforms_to_sync = 7 [default = 4294967295];
	optional uint32 cell_id = 9;
	optional bool can_encrypt = 10;
	optional bool is_shared_file = 11;
	optional uint32 deprecated_realm = 12;
	optional uint64 upload_batch_id = 13;
}

message CCloud_ClientBeginFileUpload_Response {
	optional bool encrypt_file = 1;
	repeated .ClientCloudFileUploadBlockDetails block_requests = 2;
}

message CCloud_ClientCommitFileUpload_Request {
	optional bool transfer_succeeded = 1;
	optional uint32 appid = 2;
	optional bytes file_sha = 3;
	optional string filename = 4;
}

message CCloud_ClientCommitFileUpload_Response {
	optional bool file_committed = 1;
}

message CCloud_ClientConflictResolution_Notification {
	optional uint32 appid = 1;
	optional bool chose_local_files = 2;
}

message CCloud_ClientDeleteFile_Request {
	optional uint32 appid = 1;
	optional string filename = 2;
	optional bool is_explicit_delete = 3;
	optional uint64 upload_batch_id = 4;
}

message CCloud_ClientDeleteFile_Response {
}

message CCloud_ClientFileDownload_Request {
	optional uint32 appid = 1;
	optional string filename = 2;
	optional uint32 realm = 3;
	optional bool force_proxy = 4;
}

message CCloud_ClientFileDownload_Response {
	optional uint32 appid = 1;
	optional uint32 file_size = 2;
	optional uint32 raw_file_size = 3;
	optional bytes sha_file = 4;
	optional uint64 time_stamp = 5;
	optional bool is_explicit_delete = 6;
	optional string url_host = 7;
	optional string url_path = 8;
	optional bool use_https = 9;
	repeated .CCloud_ClientFileDownload_Response_HTTPHeaders request_headers = 10;
	optional bool encrypted = 11;
}

message CCloud_ClientFileDownload_Response_HTTPHeaders {
	optional string name = 1;
	optional string value = 2;
}

message CCloud_ClientGetAppQuotaUsage_Request {
	optional uint32 appid = 1;
}

message CCloud_ClientGetAppQuotaUsage_Response {
	optional uint32 existing_files = 1;
	optional uint64 existing_bytes = 2;
	optional uint32 max_num_files = 3;
	optional uint64 max_num_bytes = 4;
}

message CCloud_ClientLogUploadCheck_Notification {
	optional uint64 client_id = 1;
}

message CCloud_ClientLogUploadComplete_Notification {
	optional uint64 client_id = 1;
	optional uint64 request_id = 2;
}

message CCloud_ClientLogUploadRequest_Notification {
	optional uint64 request_id = 1;
}

message CCloud_CommitHTTPUpload_Request {
	optional bool transfer_succeeded = 1;
	optional uint32 appid = 2;
	optional string file_sha = 3;
	optional string filename = 4;
}

message CCloud_CommitHTTPUpload_Response {
	optional bool file_committed = 1;
}

message CCloud_CommitUGCUpload_Request {
	optional bool transfer_succeeded = 1;
	optional uint32 appid = 2;
	optional fixed64 ugcid = 3;
}

message CCloud_CommitUGCUpload_Response {
	optional bool file_committed = 1;
}

message CCloud_CompleteAppUploadBatch_Notification {
	optional uint32 appid = 1;
	optional uint64 batch_id = 2;
	optional uint32 batch_eresult = 3;
}

message CCloud_CompleteAppUploadBatch_Request {
	optional uint32 appid = 1;
	optional uint64 batch_id = 2;
	optional uint32 batch_eresult = 3;
}

message CCloud_CompleteAppUploadBatch_Response {
}

message CCloud_Delete_Request {
	optional string filename = 1;
	optional uint32 appid = 2;
	optional uint64 upload_batch_id = 3;
}

message CCloud_Delete_Response {
}

message CCloud_EnumerateUserFiles_Request {
	optional uint32 appid = 1;
	optional bool extended_details = 2;
	optional uint32 count = 3;
	optional uint32 start_index = 4;
}

message CCloud_EnumerateUserFiles_Response {
	repeated .CCloud_UserFile files = 1;
	optional uint32 total_files = 2;
}

message CCloud_ExternalStorageTransferReport_Notification {
	optional string host = 1;
	optional string path = 2;
	optional bool is_upload = 3;
	optional bool success = 4;
	optional uint32 http_status_code = 5;
	optional uint64 bytes_expected = 6;
	optional uint64 bytes_actual = 7;
	optional uint32 duration_ms = 8;
	optional uint32 cellid = 9;
	optional bool proxied = 10;
	optional bool ipv6_local = 11;
	optional bool ipv6_remote = 12;
	optional uint32 time_to_connect_ms = 13;
	optional uint32 time_to_send_req_ms = 14;
	optional uint32 time_to_first_byte_ms = 15;
	optional uint32 time_to_last_byte_ms = 16;
}

message CCloud_GetAppFileChangelist_Request {
	optional uint32 appid = 1;
	optional uint64 synced_change_number = 2;
}

message CCloud_GetAppFileChangelist_Response {
	optional uint64 current_change_number = 1;
	repeated .CCloud_AppFileInfo files = 2;
	optional bool is_only_delta = 3;
	repeated string path_prefixes = 4;
	repeated string machine_names = 5;
	optional uint64 app_buildid_hwm = 6;
}

message CCloud_GetClientEncryptionKey_Request {
}

message CCloud_GetClientEncryptionKey_Response {
	optional bytes key = 1;
	optional int32 crc = 2;
}

message CCloud_GetFileDetails_Request {
	optional uint64 ugcid = 1;
	optional uint32 appid = 2;
}

message CCloud_GetFileDetails_Response {
	optional .CCloud_UserFile details = 1;
	optional string rangecheck_host = 2;
}

message CCloud_GetSingleFileInfo_Request {
	optional uint32 app_id = 1;
	optional string file_name = 2;
}

message CCloud_GetSingleFileInfo_Response {
	optional uint32 app_id = 2;
	optional string file_name = 3;
	optional bytes sha_file = 4;
	optional uint64 time_stamp = 5;
	optional uint32 raw_file_size = 6;
	optional bool is_explicit_delete = 7;
}

message CCloud_ShareFile_Request {
	optional uint32 app_id = 1;
	optional string file_name = 2;
}

message CCloud_ShareFile_Response {
	optional fixed64 hcontent = 1 [default = 18446744073709551615];
}

message CCloud_UserFile {
	optional uint32 appid = 1;
	optional uint64 ugcid = 2;
	optional string filename = 3;
	optional uint64 timestamp = 4;
	optional uint32 file_size = 5;
	optional string url = 6;
	optional fixed64 steamid_creator = 7;
	optional uint32 flags = 8;
	repeated string platforms_to_sync = 9;
	optional string file_sha = 10;
	optional uint32 compressed_file_size = 11;
}

message ClientCloudFileUploadBlockDetails {
	optional string url_host = 1;
	optional string url_path = 2;
	optional bool use_https = 3;
	optional int32 http_method = 4;
	repeated .ClientCloudFileUploadBlockDetails_HTTPHeaders request_headers = 5;
	optional uint64 block_offset = 6;
	optional uint32 block_length = 7;
	optional bytes explicit_body_data = 8;
	optional bool may_parallelize = 9;
}

message ClientCloudFileUploadBlockDetails_HTTPHeaders {
	optional string name = 1;
	optional string value = 2;
}

service Cloud {
	// ePrivilege=1
	rpc BeginAppUploadBatch (.CCloud_BeginAppUploadBatch_Request) returns (.CCloud_BeginAppUploadBatch_Response);
	// ePrivilege=1
	rpc BeginHTTPUpload (.CCloud_BeginHTTPUpload_Request) returns (.CCloud_BeginHTTPUpload_Response);
	// ePrivilege=1
	rpc BeginUGCUpload (.CCloud_BeginUGCUpload_Request) returns (.CCloud_BeginUGCUpload_Response);
	// ePrivilege=1
	rpc CDNReport (.CCloud_CDNReport_Notification) returns (.NoResponse);
	// ePrivilege=1
	rpc ClientBeginFileUpload (.CCloud_ClientBeginFileUpload_Request) returns (.CCloud_ClientBeginFileUpload_Response);
	// ePrivilege=1
	rpc ClientCommitFileUpload (.CCloud_ClientCommitFileUpload_Request) returns (.CCloud_ClientCommitFileUpload_Response);
	// ePrivilege=1
	rpc ClientConflictResolution (.CCloud_ClientConflictResolution_Notification) returns (.NoResponse);
	// ePrivilege=1
	rpc ClientDeleteFile (.CCloud_ClientDeleteFile_Request) returns (.CCloud_ClientDeleteFile_Response);
	// ePrivilege=1
	rpc ClientFileDownload (.CCloud_ClientFileDownload_Request) returns (.CCloud_ClientFileDownload_Response);
	// bConstMethod=true, ePrivilege=1
	rpc ClientGetAppQuotaUsage (.CCloud_ClientGetAppQuotaUsage_Request) returns (.CCloud_ClientGetAppQuotaUsage_Response);
	// ePrivilege=1
	rpc ClientLogUploadCheck (.CCloud_ClientLogUploadCheck_Notification) returns (.NoResponse);
	// ePrivilege=1
	rpc ClientLogUploadComplete (.CCloud_ClientLogUploadComplete_Notification) returns (.NoResponse);
	// ePrivilege=1
	rpc CommitHTTPUpload (.CCloud_CommitHTTPUpload_Request) returns (.CCloud_CommitHTTPUpload_Response);
	// ePrivilege=1
	rpc CommitUGCUpload (.CCloud_CommitUGCUpload_Request) returns (.CCloud_CommitUGCUpload_Response);
	// ePrivilege=1
	rpc CompleteAppUploadBatch (.CCloud_CompleteAppUploadBatch_Notification) returns (.NoResponse);
	// ePrivilege=1
	rpc CompleteAppUploadBatchBlocking (.CCloud_CompleteAppUploadBatch_Request) returns (.CCloud_CompleteAppUploadBatch_Response);
	// ePrivilege=1
	rpc Delete (.CCloud_Delete_Request) returns (.CCloud_Delete_Response);
	// bConstMethod=true, ePrivilege=1
	rpc EnumerateUserFiles (.CCloud_EnumerateUserFiles_Request) returns (.CCloud_EnumerateUserFiles_Response);
	// ePrivilege=1
	rpc ExternalStorageTransferReport (.CCloud_ExternalStorageTransferReport_Notification) returns (.NoResponse);
	// bConstMethod=true, ePrivilege=1
	rpc GetAppFileChangelist (.CCloud_GetAppFileChangelist_Request) returns (.CCloud_GetAppFileChangelist_Response);
	// ePrivilege=1
	rpc GetClientEncryptionKey (.CCloud_GetClientEncryptionKey_Request) returns (.CCloud_GetClientEncryptionKey_Response);
	// bConstMethod=true, ePrivilege=2, eWebAPIKeyRequirement=2
	rpc GetFileDetails (.CCloud_GetFileDetails_Request) returns (.CCloud_GetFileDetails_Response);
	// bConstMethod=true, ePrivilege=1
	rpc GetSingleFileInfo (.CCloud_GetSingleFileInfo_Request) returns (.CCloud_GetSingleFileInfo_Response);
	// ePrivilege=1
	rpc ResumeAppSession (.CCloud_AppSessionResume_Request) returns (.CCloud_AppSessionResume_Response);
	// ePrivilege=1
	rpc ShareFile (.CCloud_ShareFile_Request) returns (.CCloud_ShareFile_Response);
	// ePrivilege=1
	rpc SignalAppExitSyncDone (.NotImplemented) returns (.NoResponse);
	// ePrivilege=1
	rpc SignalAppLaunchIntent (.CCloud_AppLaunchIntent_Request) returns (.CCloud_AppLaunchIntent_Response);
	// ePrivilege=1
	rpc SuspendAppSession (.CCloud_AppSessionSuspend_Request) returns (.CCloud_AppSessionSuspend_Response);
}

service CloudClient {
	rpc ClientLogUploadRequest (.CCloud_ClientLogUploadRequest_Notification) returns (.NoResponse);
	rpc NotifyAppStateChange (.CCloud_AppCloudStateChange_Notification) returns (.NoResponse);
}

